don't malloc pic->iseq

This commit is contained in:
Yuichi Nishiwaki 2015-06-19 03:10:11 +09:00
parent 78bd3047f8
commit db0767c931
3 changed files with 4 additions and 17 deletions

View File

@ -45,9 +45,9 @@ extern "C" {
#include "picrin/value.h"
typedef struct pic_code pic_code;
typedef struct pic_state pic_state;
#include "picrin/irep.h"
#include "picrin/file.h"
typedef struct pic_jmpbuf {
@ -139,6 +139,7 @@ struct pic_state {
struct pic_reader *reader;
xFILE files[XOPEN_MAX];
pic_code iseq[2]; /* for pic_apply_trampoline */
bool gc_enable;
struct pic_heap *heap;
@ -148,7 +149,6 @@ struct pic_state {
pic_value err;
pic_code *iseq; /* for pic_apply_trampoline */
char *native_stack_start;
};
@ -272,7 +272,6 @@ pic_value pic_fdisplay(pic_state *, pic_value, xFILE *);
#include "picrin/dict.h"
#include "picrin/error.h"
#include "picrin/gc.h"
#include "picrin/irep.h"
#include "picrin/lib.h"
#include "picrin/macro.h"
#include "picrin/pair.h"

View File

@ -49,7 +49,7 @@ enum pic_opcode {
OP_STOP
};
struct pic_code {
typedef struct {
enum pic_opcode insn;
union {
int i;
@ -59,7 +59,7 @@ struct pic_code {
int idx;
} r;
} u;
};
} pic_code;
#define PIC_INIT_CODE_I(code, op, ival) do { \
code.insn = op; \

View File

@ -216,13 +216,6 @@ pic_open(int argc, char *argv[], char **envp, pic_allocf allocf)
goto EXIT_ARENA;
}
/* trampoline iseq */
pic->iseq = allocf(NULL, 2 * sizeof(pic_code));
if (! pic->iseq) {
goto EXIT_ISEQ;
}
/* memory heap */
pic->heap = pic_heap_open(pic);
@ -393,8 +386,6 @@ pic_open(int argc, char *argv[], char **envp, pic_allocf allocf)
return pic;
EXIT_ISEQ:
allocf(pic->arena, 0);
EXIT_ARENA:
allocf(pic->xp, 0);
EXIT_XP:
@ -456,9 +447,6 @@ pic_close(pic_state *pic)
allocf(pic->cibase, 0);
allocf(pic->xpbase, 0);
/* free trampoline iseq */
allocf(pic->iseq, 0);
/* free global stacks */
xh_destroy(&pic->syms);