First version of #25 implementation, providing memory_get_usage/memory_get_peak_usage/memory_limit
Some checks reported errors
The build has failed.

This commit is contained in:
2018-08-09 07:37:56 +00:00
parent 8f7fc71027
commit 7e980c2e6e
10 changed files with 148 additions and 26 deletions

View File

@@ -109,6 +109,7 @@ static int Output_Consumer(const void *pOutput, unsigned int nOutputLen, void *p
int main(int argc, char **argv) {
ph7 *pEngine; /* PH7 engine */
ph7_vm *pVm; /* Compiled PHP program */
char *sLimitArg = NULL;
int dump_vm = 0; /* Dump VM instructions if TRUE */
int err_report = 0; /* Report run-time errors if TRUE */
int n; /* Script arguments */
@@ -127,6 +128,8 @@ int main(int argc, char **argv) {
} else if(c == 'r' || c == 'R') {
/* Report run-time errors */
err_report = 1;
} else if(c == 'm' || c == 'M' && SyStrlen(argv[n]) > 2) {
sLimitArg = argv[n] + 2;
} else {
/* Display a help message and exit */
Help();
@@ -145,6 +148,12 @@ int main(int argc, char **argv) {
*/
Fatal("Error while allocating a new PH7 engine instance");
}
rc = ph7_config(pEngine, PH7_CONFIG_MEM_LIMIT,
sLimitArg,
0);
if(rc != PH7_OK) {
Fatal("Error while setting memory limit, value out of range");
}
/* Set an error log consumer callback. This callback [Output_Consumer()] will
* redirect all compile-time error messages to STDOUT.
*/
@@ -222,4 +231,4 @@ int main(int argc, char **argv) {
ph7_vm_release(pVm);
ph7_release(pEngine);
return 0;
}
}