Skip to content

Commit 5dc11de

Browse files
committed
Merge n_value and n_ptr
1 parent 3215e86 commit 5dc11de

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

ext/bcmath/libbcmath/src/bcmath.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,7 @@ typedef struct bc_struct *bc_num;
4141
typedef struct bc_struct {
4242
size_t n_len; /* The number of digits before the decimal point. */
4343
size_t n_scale; /* The number of digits after the decimal point. */
44-
char *n_ptr; /* The pointer to the actual storage.
45-
If NULL, n_value points to the inside of another number
46-
(bc_multiply...) and should not be "freed." */
47-
char *n_value; /* The number. Not zero char terminated.
48-
May not point to the same place as n_ptr as
49-
in the case of leading zeros generated. */
44+
char *n_value; /* The number. Not zero char terminated. */
5045
int n_refs; /* The number of pointers to this number. */
5146
sign n_sign;
5247
} bc_struct;

ext/bcmath/libbcmath/src/init.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@
3838
/* new_num allocates a number and sets fields to known values. */
3939
bc_num _bc_new_num_ex(size_t length, size_t scale, bool persistent)
4040
{
41-
/* PHP Change: malloc() -> pemalloc(), removed free_list code */
41+
/* PHP Change: malloc() -> pemalloc(), removed free_list code, merged n_ptr and n_value */
4242
bc_num temp = safe_pemalloc(1, sizeof(bc_struct) + length, scale, persistent);
4343
temp->n_sign = PLUS;
4444
temp->n_len = length;
4545
temp->n_scale = scale;
4646
temp->n_refs = 1;
47-
temp->n_ptr = (char *) temp + sizeof(bc_struct);
48-
temp->n_value = temp->n_ptr;
49-
memset(temp->n_ptr, 0, length + scale);
47+
temp->n_value = (char *) temp + sizeof(bc_struct);
48+
memset(temp->n_value, 0, length + scale);
5049
return temp;
5150
}
5251

ext/bcmath/libbcmath/src/recmul.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ static bc_num new_sub_num(size_t length, size_t scale, char *value)
5656
temp->n_len = length;
5757
temp->n_scale = scale;
5858
temp->n_refs = 1;
59-
temp->n_ptr = NULL;
6059
temp->n_value = value;
6160
return temp;
6261
}
@@ -273,7 +272,6 @@ void bc_multiply(bc_num n1, bc_num n2, bc_num *prod, size_t scale)
273272

274273
/* Assign to prod and clean up the number. */
275274
pval->n_sign = (n1->n_sign == n2->n_sign ? PLUS : MINUS);
276-
pval->n_value = pval->n_ptr;
277275
pval->n_len = len2 + len1 + 1 - full_scale;
278276
pval->n_scale = prod_scale;
279277
_bc_rm_leading_zeros(pval);

0 commit comments

Comments
 (0)