First version of #25 implementation, providing memory_get_usage/memory_get_peak_usage/memory_limit
All checks were successful
The build was successful.
All checks were successful
The build was successful.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user