File: function.c

package info (click to toggle)
elk 3.0-6
  • links: PTS
  • area: main
  • in suites: potato, slink
  • size: 4,068 kB
  • ctags: 3,123
  • sloc: ansic: 20,686; lisp: 5,232; makefile: 419; awk: 91; sh: 21
file content (37 lines) | stat: -rw-r--r-- 792 bytes parent folder | download | duplicates (3)
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
#include "xt.h"

static max_functions = 512;
static Object Functions;

int Register_Function (x) Object x; {
    register i;
    Object v;
    GC_Node;

    for (i = 0; i < max_functions; i++)
	if (Nullp (VECTOR(Functions)->data[i])) break;
    if (i == max_functions) {
	max_functions *= 2;
	GC_Link (x);
	v = Make_Vector (max_functions, Null);
	GC_Unlink;
	bcopy ((char *)VECTOR(Functions)->data, (char *)VECTOR(v)->data,
	    i * sizeof (Object));
	Functions = v;
    }
    VECTOR(Functions)->data[i] = x;
    return i;
}

Object Get_Function (i) int i; {
    return VECTOR(Functions)->data[i];
}

void Deregister_Function (i) int i; {
    VECTOR(Functions)->data[i] = Null;
}

elk_init_xt_function () {
    Functions = Make_Vector (max_functions, Null);
    Global_GC_Link (Functions);
}