First version of #25 implementation, providing memory_get_usage/memory_get_peak_usage/memory_limit
This commit is contained in:
28
engine/api.c
28
engine/api.c
@@ -120,6 +120,34 @@ static sxi32 EngineConfig(ph7 *pEngine, sxi32 nOp, va_list ap) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PH7_CONFIG_MEM_LIMIT: {
|
||||
char *iMaxStr = va_arg(ap, char *);
|
||||
if(!iMaxStr) {
|
||||
break;
|
||||
}
|
||||
char *iMaxRem;
|
||||
sxu64 iMax;
|
||||
SyStrToInt64(iMaxStr, strlen(iMaxStr), (void *)&iMax, &iMaxRem);
|
||||
if(iMaxRem) {
|
||||
switch(*iMaxRem) {
|
||||
case 'G':
|
||||
case 'g':
|
||||
iMax *= 1024;
|
||||
case 'M':
|
||||
case 'm':
|
||||
iMax *= 1024;
|
||||
case 'K':
|
||||
case 'k':
|
||||
iMax *= 1024;
|
||||
}
|
||||
}
|
||||
if(iMax >= 1024 * 100 && iMax <= LONG_MAX) {
|
||||
pEngine->sAllocator.pHeap.iMax = iMax;
|
||||
} else {
|
||||
rc = PH7_CORRUPT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PH7_CONFIG_ERR_ABORT:
|
||||
/* Reserved for future use */
|
||||
break;
|
||||
|
Reference in New Issue
Block a user