diff options
author | foobar <sniper@php.net> | 2003-12-09 23:59:33 +0000 |
---|---|---|
committer | foobar <sniper@php.net> | 2003-12-09 23:59:33 +0000 |
commit | a08c1e4dce535ba70a5e3d954fce1a3b05411f4b (patch) | |
tree | 0a8fea3582a94b82772086262af675d0bdddb60d /ext/bcmath/libbcmath/src | |
parent | 398ab9756a6c6c64f855ed578dd86a9d31168f6e (diff) | |
download | php-git-a08c1e4dce535ba70a5e3d954fce1a3b05411f4b.tar.gz |
- Brought ext/bcmath to the new millennium
# consistency..
Diffstat (limited to 'ext/bcmath/libbcmath/src')
-rw-r--r-- | ext/bcmath/libbcmath/src/bcmath.h | 8 | ||||
-rw-r--r-- | ext/bcmath/libbcmath/src/init.c | 29 |
2 files changed, 21 insertions, 16 deletions
diff --git a/ext/bcmath/libbcmath/src/bcmath.h b/ext/bcmath/libbcmath/src/bcmath.h index 1c26a3d93d..ce68f0da4e 100644 --- a/ext/bcmath/libbcmath/src/bcmath.h +++ b/ext/bcmath/libbcmath/src/bcmath.h @@ -101,9 +101,9 @@ typedef struct bc_struct _PROTOTYPE(void bc_init_numbers, (TSRMLS_D)); -_PROTOTYPE(bc_num bc_new_num, (int length, int scale)); +_PROTOTYPE(bc_num _bc_new_num_ex, (int length, int scale, int persistent)); -_PROTOTYPE(void bc_free_num, (bc_num *num)); +_PROTOTYPE(void _bc_free_num_ex, (bc_num *num, int persistent)); _PROTOTYPE(bc_num bc_copy_num, (bc_num num)); @@ -155,4 +155,8 @@ _PROTOTYPE(void bc_out_num, (bc_num num, int o_base, void (* out_char)(int), _PROTOTYPE(void bc_rt_warn, (char *mesg ,...)); _PROTOTYPE(void bc_rt_error, (char *mesg ,...)); _PROTOTYPE(void bc_out_of_memory, (void)); + +#define bc_new_num(length, scale) _bc_new_num_ex((length), (scale), 0) +#define bc_free_num(num) _bc_free_num_ex((num), 0) + #endif diff --git a/ext/bcmath/libbcmath/src/init.c b/ext/bcmath/libbcmath/src/init.c index d540a88060..cd45b9fbc1 100644 --- a/ext/bcmath/libbcmath/src/init.c +++ b/ext/bcmath/libbcmath/src/init.c @@ -45,19 +45,19 @@ /* new_num allocates a number and sets fields to known values. */ bc_num -bc_new_num (length, scale) - int length, scale; +_bc_new_num_ex (length, scale, persistent) + int length, scale, persistent; { bc_num temp; - /* PHP Change: malloc() -> emalloc(), removed free_list code */ - temp = (bc_num) emalloc (sizeof(bc_struct)+length+scale); + /* PHP Change: malloc() -> pemalloc(), removed free_list code */ + temp = (bc_num) pemalloc (sizeof(bc_struct)+length+scale, persistent); #if 0 if (_bc_Free_list != NULL) { temp = _bc_Free_list; _bc_Free_list = temp->n_next; } else { - temp = (bc_num) emalloc (sizeof(bc_struct)); + temp = (bc_num) pemalloc (sizeof(bc_struct), persistent); if (temp == NULL) bc_out_of_memory (); } #endif @@ -65,8 +65,8 @@ bc_new_num (length, scale) temp->n_len = length; temp->n_scale = scale; temp->n_refs = 1; - /* PHP Change: malloc() -> emalloc() */ - temp->n_ptr = (char *) emalloc (length+scale); + /* PHP Change: malloc() -> pemalloc() */ + temp->n_ptr = (char *) pemalloc (length+scale, persistent); if (temp->n_ptr == NULL) bc_out_of_memory(); temp->n_value = temp->n_ptr; memset (temp->n_ptr, 0, length+scale); @@ -78,16 +78,17 @@ bc_new_num (length, scale) frees the storage if reference count is zero. */ void -bc_free_num (num) +_bc_free_num_ex (num, persistent) bc_num *num; + int persistent; { if (*num == NULL) return; (*num)->n_refs--; if ((*num)->n_refs == 0) { if ((*num)->n_ptr) - /* PHP Change: free() -> efree(), removed free_list code */ - efree ((*num)->n_ptr); - efree(*num); + /* PHP Change: free() -> pefree(), removed free_list code */ + pefree ((*num)->n_ptr, persistent); + pefree(*num, persistent); #if 0 (*num)->n_next = _bc_Free_list; _bc_Free_list = *num; @@ -102,10 +103,10 @@ bc_free_num (num) void bc_init_numbers (TSRMLS_D) { - BCG(_zero_) = bc_new_num (1,0); - BCG(_one_) = bc_new_num (1,0); + BCG(_zero_) = _bc_new_num_ex (1,0,1); + BCG(_one_) = _bc_new_num_ex (1,0,1); BCG(_one_)->n_value[0] = 1; - BCG(_two_) = bc_new_num (1,0); + BCG(_two_) = _bc_new_num_ex (1,0,1); BCG(_two_)->n_value[0] = 2; } |