Skip to content

Commit 7e937d7

Browse files
committed
WIP
1 parent d496a8a commit 7e937d7

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

ext/bcmath/bcmath.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -799,12 +799,11 @@ static inline bcmath_number_obj_t *get_bcmath_number_from_zval(zval *zv) {
799799

800800
static zend_object *bcmath_number_create(zend_class_entry *ce)
801801
{
802-
bcmath_number_obj_t *intern;
802+
bcmath_number_obj_t *intern = zend_object_alloc(sizeof(bcmath_number_obj_t), ce);
803803

804-
intern = zend_object_alloc(sizeof(bcmath_number_obj_t), ce);
805804
zend_object_std_init(&intern->std, ce);
806805
object_properties_init(&intern->std, ce);
807-
rebuild_object_properties(&intern->std);
806+
808807
intern->num = NULL;
809808
intern->value = NULL;
810809
intern->scale = 1;
@@ -1022,7 +1021,7 @@ static zend_result bcmath_number_do_operation(uint8_t opcode, zval *ret_val, zva
10221021
ZVAL_OBJ(ret_val, &intern->std);
10231022

10241023
/* For increment and decrement, etc */
1025-
if (ret == SUCCESS && op1 == &op1_copy) {
1024+
if (op1 == &op1_copy) {
10261025
zval_ptr_dtor(op1);
10271026
}
10281027

@@ -1056,7 +1055,7 @@ static inline zend_string *bcmath_number_value_to_str(bcmath_number_obj_t *inter
10561055
return intern->value;
10571056
}
10581057

1059-
static HashTable *bcmath_number_get_properties(zend_object *obj, zend_prop_purpose purpose)
1058+
static HashTable *bcmath_number_get_properties_for(zend_object *obj, zend_prop_purpose purpose)
10601059
{
10611060
switch (purpose) {
10621061
case ZEND_PROP_PURPOSE_DEBUG:
@@ -1130,7 +1129,7 @@ static void bcmath_number_register_class(void)
11301129
bcmath_number_obj_handlers.do_operation = bcmath_number_do_operation;
11311130
bcmath_number_obj_handlers.compare = bcmath_number_compare;
11321131
bcmath_number_obj_handlers.read_property = bcmath_number_read_property;
1133-
bcmath_number_obj_handlers.get_properties_for = bcmath_number_get_properties;
1132+
bcmath_number_obj_handlers.get_properties_for = bcmath_number_get_properties_for;
11341133
bcmath_number_obj_handlers.cast_object = bcmath_number_cast_object;
11351134
bcmath_number_obj_handlers.get_gc = bcmath_number_get_gc;
11361135
}

ext/bcmath/libbcmath/src/long2num.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ static inline size_t bc_count_len_in_vector(BC_VECTOR vector)
4040
}
4141

4242
if (tmp >= 10) {
43-
tmp += 2;
43+
len += 2;
4444
} else {
45-
tmp += 1;
45+
len += 1;
4646
}
4747

4848
return len;
@@ -109,12 +109,12 @@ void bc_long2num(bc_num *num, zend_long lval)
109109
end -= BC_VECTOR_SIZE;
110110
bc_bulk_convert_vector_to_num(mid, end);
111111
end -= BC_VECTOR_SIZE;
112-
bc_convert_vector_to_num(low, ptr, end);
112+
bc_convert_vector_to_num(high, ptr, end);
113113
break;
114114
case 2:
115115
bc_bulk_convert_vector_to_num(low, end);
116116
end -= BC_VECTOR_SIZE;
117-
bc_convert_vector_to_num(low, ptr, end);
117+
bc_convert_vector_to_num(mid, ptr, end);
118118
break;
119119
case 1:
120120
bc_convert_vector_to_num(low, ptr, end);

ext/bcmath/php_bcmath.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ ZEND_EXTERN_MODULE_GLOBALS(bcmath)
4848
#define BC_MATH_NUMBER_MAX_EX_SCALE 10
4949

5050
typedef struct _bcmath_number_obj_t {
51-
zend_object std;
52-
bc_num num;
53-
size_t scale;
5451
zend_string *value;
52+
size_t scale;
53+
bc_num num;
54+
zend_object std;
5555
} bcmath_number_obj_t;
5656

5757
typedef enum {

0 commit comments

Comments
 (0)