Page MenuHomePhorge

roots.c
No OneTemporary

Size
866 B
Referenced Files
None
Subscribers
None
#include "ant.h"
#include "gc.h"
#include "arena.h"
#include "internal.h"
jshdl_t js_root(struct js *js, jsval_t val) {
if (js->gc_roots_len >= js->gc_roots_cap) {
int new_cap = js->gc_roots_cap ? js->gc_roots_cap * 2 : GC_ROOTS_INITIAL_CAP;
jsval_t *new_roots = ant_realloc(js->gc_roots, new_cap * sizeof(jsval_t));
if (!new_roots) return -1;
js->gc_roots = new_roots;
js->gc_roots_cap = new_cap;
}
int idx = js->gc_roots_len++;
js->gc_roots[idx] = val;
return idx;
}
jsval_t js_deref(struct js *js, jshdl_t h) {
if (h < 0 || h >= js->gc_roots_len) return js_mkundef();
return js->gc_roots[h];
}
void js_unroot(struct js *js, jshdl_t h) {
if (h >= 0 && h == js->gc_roots_len - 1) js->gc_roots_len--;
}
void js_root_update(struct js *js, jshdl_t h, jsval_t val) {
if (h >= 0 && h < js->gc_roots_len) js->gc_roots[h] = val;
}

File Metadata

Mime Type
text/x-c
Expires
Wed, Jun 17, 1:12 PM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
536771
Default Alt Text
roots.c (866 B)

Event Timeline