This commit is contained in:
virusdefender 2016-01-12 19:22:18 +08:00
parent 5a6043101a
commit 865ad36a9c
3 changed files with 9 additions and 17 deletions

View File

@ -7,7 +7,7 @@ static PyObject *error;
static PyObject *judger_run(PyObject *self, PyObject *args, PyObject *kwargs) {
struct config config;
struct result result;
struct result result = {0, 0, 0, 0, 0};
config.path = config.in_file = config.out_file = NULL;
static char *kwargs_list[] = {"path", "in_file", "out_file", "max_cpu_time", "max_memory", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sssii", kwargs_list, &(config.path), &(config.in_file),
@ -32,7 +32,7 @@ static PyObject *judger_run(PyObject *self, PyObject *args, PyObject *kwargs) {
return NULL;
}
printf("%s %s %s %d %d", config.path, config.in_file, config.out_file, config.max_cpu_time, config.max_memory);
// printf("%s %s %s %d %d", config.path, config.in_file, config.out_file, config.max_cpu_time, config.max_memory);
run(&config, &result);
return Py_BuildValue("{s: i, s:l, s:i, s:i, s:i, s:i}",
"cpu_time", result.cpu_time, "memory", result.memory, "real_time", result.real_time, "signal",

View File

@ -2,8 +2,6 @@
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <sys/time.h>
#include "runner.h"
@ -93,7 +91,7 @@ int run(struct config *config, struct result *result) {
result->flag = RUNTIME_ERROR;
}
}
else{
else {
if (result->memory > config->max_memory) {
result->flag = MEMORY_LIMIT_EXCEEDED;
}
@ -130,9 +128,9 @@ int main() {
config.max_cpu_time = 4300;
config.max_memory = 180000000;
config.path = (char *)malloc(200);
config.in_file = (char *)malloc(200);
config.out_file = (char *)malloc(200);
config.path = (char *) malloc(200);
config.in_file = (char *) malloc(200);
config.out_file = (char *) malloc(200);
strcpy(config.path, "/Users/virusdefender/Desktop/judger/limit");
strcpy(config.in_file, "/Users/virusdefender/Desktop/judger/in");

12
test.c
View File

@ -1,15 +1,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/resource.h>
int main()
{
int main() {
int *a = NULL;
// 150M
int v = 150000000;
a = (int *)malloc(v);
if(a == NULL){
a = (int *) malloc(v);
if (a == NULL) {
printf("error\n");
}
else {