diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-05-09 06:57:46 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-05-09 06:57:46 -0700 |
commit | f3cd8ecb633e0c76338017bd9e4f1ea9ffdfcbb5 (patch) | |
tree | 9dc7fd91b7078aad4022d567125ffce88f72dc92 /lib.c | |
parent | 179218caf4521209cbbe4d6b1267ed0aa3d70245 (diff) | |
download | txr-f3cd8ecb633e0c76338017bd9e4f1ea9ffdfcbb5.tar.gz txr-f3cd8ecb633e0c76338017bd9e4f1ea9ffdfcbb5.tar.bz2 txr-f3cd8ecb633e0c76338017bd9e4f1ea9ffdfcbb5.zip |
cptr: new functions.
* eval.c (eval_init): Register cptr-int, ctpr-obj, cptr-zap
and cptr-free functions and cptr-null variable.
* lib.c (cptr_int, cptr_obj, cptr_zap, cptr_free): New
functions.
* lib.c (cptr_int, cptr_obj, cptr_zap, cptr_free): Declared.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -7402,6 +7402,31 @@ val cptr(mem_t *ptr) return cobj(ptr, cptr_s, &cptr_ops); } +val cptr_int(val n) +{ + return if3(missingp(n), cptr(0), cptr(coerce(mem_t *, c_num(n)))); +} + +val cptr_obj(val obj) +{ + return cptr(coerce(mem_t *, obj)); +} + +val cptr_zap(val cptr) +{ + (void) cobj_handle(cptr, cptr_s); + cptr->co.handle = 0; + return cptr; +} + +val cptr_free(val cptr) +{ + (void) cobj_handle(cptr, cptr_s); + free(cptr->co.handle); + cptr->co.handle = 0; + return cptr; +} + mem_t *cptr_get(val cptr) { return cobj_handle(cptr, cptr_s); |