Implement PH7_VmDestroyMemObj() to forcibly destroy a memory object.
The build was successful.
Details
The build was successful.
Details
This commit is contained in:
parent
d09a33da55
commit
0bef248298
24
engine/vm.c
24
engine/vm.c
|
@ -7507,6 +7507,30 @@ PH7_PRIVATE sxi32 PH7_VmUnsetMemObj(ph7_vm *pVm, sxu32 nObjIdx, int bForce) {
|
|||
}
|
||||
return SXRET_OK;
|
||||
}
|
||||
/*
|
||||
* Forcibly destroy a memory object [i.e: a ph7_value], remove it from
|
||||
* the current frame, the reference table and discard it's contents.
|
||||
* This function never fail and always return SXRET_OK.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_VmDestroyMemObj(ph7_vm *pVm, ph7_value *pObj) {
|
||||
VmRefObj *pRef;
|
||||
if(pObj) {
|
||||
/* Release the object */
|
||||
PH7_MemObjRelease(pObj);
|
||||
/* Remove old reference links if available */
|
||||
pRef = VmRefObjExtract(&(*pVm), pObj->nIdx);
|
||||
if(pRef) {
|
||||
/* Unlink from the reference table */
|
||||
VmRefObjUnlink(&(*pVm), pRef);
|
||||
}
|
||||
VmSlot sFree;
|
||||
/* Restore to the free list */
|
||||
sFree.nIdx = pObj->nIdx;
|
||||
sFree.pUserData = 0;
|
||||
SySetPut(&pVm->aFreeObj, (const void *)&sFree);
|
||||
}
|
||||
return SXRET_OK;
|
||||
}
|
||||
/*
|
||||
* void unset($var,...)
|
||||
* Unset one or more given variable.
|
||||
|
|
|
@ -1697,6 +1697,7 @@ PH7_PRIVATE sxi32 PH7_VmCallClassMethod(ph7_vm *pVm, ph7_class_instance *pThis,
|
|||
PH7_PRIVATE sxi32 PH7_VmCallUserFunction(ph7_vm *pVm, ph7_value *pFunc, int nArg, ph7_value **apArg, ph7_value *pResult);
|
||||
PH7_PRIVATE sxi32 PH7_VmCallUserFunctionAp(ph7_vm *pVm, ph7_value *pFunc, ph7_value *pResult, ...);
|
||||
PH7_PRIVATE sxi32 PH7_VmUnsetMemObj(ph7_vm *pVm, sxu32 nObjIdx, int bForce);
|
||||
PH7_PRIVATE sxi32 PH7_VmDestroyMemObj(ph7_vm *pVm, ph7_value *pObj);
|
||||
PH7_PRIVATE void PH7_VmRandomString(ph7_vm *pVm, char *zBuf, int nLen);
|
||||
PH7_PRIVATE ph7_class *PH7_VmExtractActiveClass(ph7_vm *pVm, sxi32 iDepth);
|
||||
PH7_PRIVATE int PH7_VmIsCallable(ph7_vm *pVm, ph7_value *pValue, int CallInvoke);
|
||||
|
|
Loading…
Reference in New Issue