malloc -> alloca

This commit is contained in:
Veit Heller
2014-11-01 14:35:23 +01:00
parent f4c005a2fc
commit c332a38b36
2 changed files with 2 additions and 4 deletions

View File

@@ -28,7 +28,7 @@ static inline void disassemble(int sp, int fp, int ip, int opcode, instruction*
}
void vm_execute(int code[], int ip, int datasize, unsigned long length){
int* data = (int *) malloc((unsigned long)datasize * sizeof(int));
int* data = (int *) alloca((size_t)datasize * sizeof(int));
int stack[MAX_SIZE];
int sp = -1;
int fp = -1;
@@ -159,9 +159,6 @@ void vm_execute(int code[], int ip, int datasize, unsigned long length){
die(127, "Exit on program failure.");
}
}
free(data);
return;
}

View File

@@ -4,6 +4,7 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <alloca.h>
#include "util.h"
#include "opcode.h"