[php-src] master: Merge n_value and n_ptr

From: Date: Wed, 01 May 2024 14:18:46 +0000
Subject: [php-src] master: Merge n_value and n_ptr
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-128293@lists.php.net to get a copy of this message
Author: Niels Dossche (nielsdos) Date: 2024-05-01T16:18:37+02:00 Commit: https://github.com/php/php-src/commit/5dc11de558ef5103a71a4ac439316b715df24cb4 Raw diff: https://github.com/php/php-src/commit/5dc11de558ef5103a71a4ac439316b715df24cb4.diff Merge n_value and n_ptr Changed paths: M ext/bcmath/libbcmath/src/bcmath.h M ext/bcmath/libbcmath/src/init.c M ext/bcmath/libbcmath/src/recmul.c Diff: diff --git a/ext/bcmath/libbcmath/src/bcmath.h b/ext/bcmath/libbcmath/src/bcmath.h index 3e005e2072cc..4b3f3510095a 100644 --- a/ext/bcmath/libbcmath/src/bcmath.h +++ b/ext/bcmath/libbcmath/src/bcmath.h @@ -41,12 +41,7 @@ typedef struct bc_struct *bc_num; typedef struct bc_struct { size_t n_len; /* The number of digits before the decimal point. */ size_t n_scale; /* The number of digits after the decimal point. */ - char *n_ptr; /* The pointer to the actual storage. - If NULL, n_value points to the inside of another number - (bc_multiply...) and should not be "freed." */ - char *n_value; /* The number. Not zero char terminated. - May not point to the same place as n_ptr as - in the case of leading zeros generated. */ + char *n_value; /* The number. Not zero char terminated. */ int n_refs; /* The number of pointers to this number. */ sign n_sign; } bc_struct; diff --git a/ext/bcmath/libbcmath/src/init.c b/ext/bcmath/libbcmath/src/init.c index 3c82af5821c7..959f47c21aa0 100644 --- a/ext/bcmath/libbcmath/src/init.c +++ b/ext/bcmath/libbcmath/src/init.c @@ -38,15 +38,14 @@ /* new_num allocates a number and sets fields to known values. */ bc_num _bc_new_num_ex(size_t length, size_t scale, bool persistent) { - /* PHP Change: malloc() -> pemalloc(), removed free_list code */ + /* PHP Change: malloc() -> pemalloc(), removed free_list code, merged n_ptr and n_value */ bc_num temp = safe_pemalloc(1, sizeof(bc_struct) + length, scale, persistent); temp->n_sign = PLUS; temp->n_len = length; temp->n_scale = scale; temp->n_refs = 1; - temp->n_ptr = (char *) temp + sizeof(bc_struct); - temp->n_value = temp->n_ptr; - memset(temp->n_ptr, 0, length + scale); + temp->n_value = (char *) temp + sizeof(bc_struct); + memset(temp->n_value, 0, length + scale); return temp; } diff --git a/ext/bcmath/libbcmath/src/recmul.c b/ext/bcmath/libbcmath/src/recmul.c index ec89c461fa18..fe6a34817d99 100644 --- a/ext/bcmath/libbcmath/src/recmul.c +++ b/ext/bcmath/libbcmath/src/recmul.c @@ -56,7 +56,6 @@ static bc_num new_sub_num(size_t length, size_t scale, char *value) temp->n_len = length; temp->n_scale = scale; temp->n_refs = 1; - temp->n_ptr = NULL; temp->n_value = value; return temp; } @@ -273,7 +272,6 @@ void bc_multiply(bc_num n1, bc_num n2, bc_num *prod, size_t scale) /* Assign to prod and clean up the number. */ pval->n_sign = (n1->n_sign == n2->n_sign ? PLUS : MINUS); - pval->n_value = pval->n_ptr; pval->n_len = len2 + len1 + 1 - full_scale; pval->n_scale = prod_scale; _bc_rm_leading_zeros(pval);

« previous php.cvs (#128293) next »