Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F9916872
roots.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
947 B
Referenced Files
None
Subscribers
None
roots.c
View Options
#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
)
{
fprintf
(
stderr
,
"FATAL: Out of memory allocating GC roots
\n
"
);
abort
();
}
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
Details
Attached
Mime Type
text/x-c
Expires
Sat, Aug 1, 8:08 PM (12 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
602510
Default Alt Text
roots.c (947 B)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment