Store float values in an union.
All checks were successful
The build was successful.

Single variable cannot have many values of different types. This also saves some memory, because union allocates memory just for one of its members.
This commit is contained in:
2018-09-07 12:04:51 +02:00
parent af1d59dab4
commit eb79ed500e
5 changed files with 41 additions and 41 deletions

View File

@@ -1217,7 +1217,7 @@ double ph7_value_to_double(ph7_value *pValue) {
if(rc != PH7_OK) {
return (double)0;
}
return (double)pValue->rVal;
return (double)pValue->x.rVal;
}
/*
* [CAPIREF: ph7_value_to_string()]
@@ -1792,7 +1792,7 @@ int ph7_value_null(ph7_value *pVal) {
int ph7_value_double(ph7_value *pVal, double Value) {
/* Invalidate any prior representation */
PH7_MemObjRelease(pVal);
pVal->rVal = (ph7_real)Value;
pVal->x.rVal = (ph7_real)Value;
MemObjSetType(pVal, MEMOBJ_REAL);
return PH7_OK;
}