Do not use NULL if possible.
The build was successful. Details

This commit is contained in:
Rafal Kupiec 2019-03-22 19:53:12 +01:00
parent 9d7a542aea
commit ff6c71db1c
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
4 changed files with 5 additions and 23 deletions

View File

@ -1791,15 +1791,6 @@ int ph7_value_char(ph7_value *pVal, int cValue) {
MemObjSetType(pVal, MEMOBJ_CHAR); MemObjSetType(pVal, MEMOBJ_CHAR);
return PH7_OK; return PH7_OK;
} }
/*
* [CAPIREF: ph7_value_null()]
* Please refer to the official documentation for function purpose and expected parameters.
*/
int ph7_value_null(ph7_value *pVal) {
/* Invalidate any prior representation and set the NULL flag */
PH7_MemObjRelease(pVal);
return PH7_OK;
}
/* /*
* [CAPIREF: ph7_value_double()] * [CAPIREF: ph7_value_double()]
* Please refer to the official documentation for function purpose and expected parameters. * Please refer to the official documentation for function purpose and expected parameters.
@ -1928,13 +1919,6 @@ int ph7_value_is_void(ph7_value *pVal) {
int ph7_value_is_string(ph7_value *pVal) { int ph7_value_is_string(ph7_value *pVal) {
return (pVal->iFlags & MEMOBJ_STRING) ? TRUE : FALSE; return (pVal->iFlags & MEMOBJ_STRING) ? TRUE : FALSE;
} }
/*
* [CAPIREF: ph7_value_is_null()]
* Please refer to the official documentation for function purpose and expected parameters.
*/
int ph7_value_is_null(ph7_value *pVal) {
return (pVal->iFlags & MEMOBJ_NULL) ? TRUE : FALSE;
}
/* /*
* [CAPIREF: ph7_value_is_numeric()] * [CAPIREF: ph7_value_is_numeric()]
* Please refer to the official documentation for function purpose and expected parameters. * Please refer to the official documentation for function purpose and expected parameters.

View File

@ -1112,7 +1112,7 @@ static void PH7_self_Const(ph7_value *pVal, void *pUserData) {
ph7_value_string(pVal, pName->zString, (int)pName->nByte); ph7_value_string(pVal, pName->zString, (int)pName->nByte);
} else { } else {
/* Expand null */ /* Expand null */
ph7_value_null(pVal); ph7_value_string(pVal, "", 0);
} }
} }
/* parent /* parent
@ -1129,7 +1129,7 @@ static void PH7_parent_Const(ph7_value *pVal, void *pUserData) {
ph7_value_string(pVal, pName->zString, (int)pName->nByte); ph7_value_string(pVal, pName->zString, (int)pName->nByte);
} else { } else {
/* Expand null */ /* Expand null */
ph7_value_null(pVal); ph7_value_string(pVal, "", 0);
} }
} }
/* /*

View File

@ -2376,9 +2376,7 @@ static int ph7_hashmap_count(ph7_context *pCtx, int nArg, ph7_value **apArg) {
return PH7_OK; return PH7_OK;
} }
if(!ph7_value_is_array(apArg[0])) { if(!ph7_value_is_array(apArg[0])) {
/* TICKET 1433-19: Handle objects */ ph7_result_int(pCtx, 1);
int res = !ph7_value_is_null(apArg[0]);
ph7_result_int(pCtx, res);
return PH7_OK; return PH7_OK;
} }
if(nArg > 1) { if(nArg > 1) {

View File

@ -151,7 +151,7 @@ static sxi32 VmJsonEncode(
ph7_context *pCtx = pData->pCtx; ph7_context *pCtx = pData->pCtx;
int iFlags = pData->iFlags; int iFlags = pData->iFlags;
int nByte; int nByte;
if(ph7_value_is_null(pIn) || ph7_value_is_resource(pIn)) { if(ph7_value_is_void(pIn) || ph7_value_is_resource(pIn)) {
/* null */ /* null */
ph7_result_string(pCtx, "null", (int)sizeof("null") - 1); ph7_result_string(pCtx, "null", (int)sizeof("null") - 1);
} else if(ph7_value_is_bool(pIn)) { } else if(ph7_value_is_bool(pIn)) {
@ -620,7 +620,7 @@ static sxi32 VmJsonDecode(
/* Reflect the JSON image */ /* Reflect the JSON image */
if(pDecoder->pIn->nType & JSON_TK_NULL) { if(pDecoder->pIn->nType & JSON_TK_NULL) {
/* Nullify the value.*/ /* Nullify the value.*/
ph7_value_null(pWorker); ph7_value_void(pWorker);
} else if(pDecoder->pIn->nType & (JSON_TK_TRUE | JSON_TK_FALSE)) { } else if(pDecoder->pIn->nType & (JSON_TK_TRUE | JSON_TK_FALSE)) {
/* Boolean value */ /* Boolean value */
ph7_value_bool(pWorker, (pDecoder->pIn->nType & JSON_TK_TRUE) ? 1 : 0); ph7_value_bool(pWorker, (pDecoder->pIn->nType & JSON_TK_TRUE) ? 1 : 0);