Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2916120
roots.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
960 B
Referenced Files
None
Subscribers
None
roots.c
View Options
#include
"ant.h"
#include
"gc.h"
#include
"arena.h"
#include
"internal.h"
// IWYU pragma: keep
jshdl_t
js_root
(
ant_t
*
js
,
jsval_t
val
)
{
if
(
js
->
gc_roots_len
>=
js
->
gc_roots_cap
)
{
jshdl_t
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
;
}
jshdl_t
idx
=
js
->
gc_roots_len
++
;
js
->
gc_roots
[
idx
]
=
val
;
return
idx
;
}
jsval_t
js_deref
(
ant_t
*
js
,
jshdl_t
h
)
{
if
(
h
<
0
||
h
>=
js
->
gc_roots_len
)
return
js_mkundef
();
return
js
->
gc_roots
[
h
];
}
void
js_unroot
(
ant_t
*
js
,
jshdl_t
h
)
{
if
(
h
>=
0
&&
h
==
js
->
gc_roots_len
-
1
)
js
->
gc_roots_len
--
;
}
void
js_root_update
(
ant_t
*
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
Thu, Mar 26, 4:41 PM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
511791
Default Alt Text
roots.c (960 B)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment