-
Notifications
You must be signed in to change notification settings - Fork 25
/
util.c
58 lines (46 loc) · 978 Bytes
/
util.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdio.h>
#include <string.h>
#include "MEM.h"
#include "DBG.h"
#include "crowbar.h"
static CRB_Interpreter *st_current_interpreter;
void *
crb_malloc(size_t size)
{
void *p;
CRB_Interpreter *inter;
inter = crb_get_current_interpreter();
p = MEM_storage_malloc(inter->interpreter_storage, size);
return p;
}
FunctionDefinition *
crb_search_function(char *name)
{
CRB_Interpreter *iter;
iter = crb_get_current_interpreter();
FunctionDefinition *pos;
for (pos = iter->function_list; pos; pos = pos->next) {
if (!strcmp(pos->name, name))
break;
}
return pos;
}
void *
crb_execute_malloc(size_t size)
{
void *p;
CRB_Interpreter *inter;
inter = crb_get_current_interpreter();
p = MEM_storage_malloc(inter->execute_storage, size);
return p;
}
CRB_Interpreter *
crb_get_current_interpreter(void)
{
return st_current_interpreter;
}
void
crb_set_current_interpreter(CRB_Interpreter *inter)
{
st_current_interpreter = inter;
}