First version of #25 implementation, providing memory_get_usage/memory_get_peak_usage/memory_limit

This commit is contained in:
2018-08-09 07:37:56 +00:00
parent 08c47b7528
commit 6a43e654b6
10 changed files with 152 additions and 26 deletions

View File

@@ -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;