Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (23 sloc) 489 Bytes
inline C <<end
typedef void(*fn_free)(void *);
/* fn may be NULL */
datum
make_pbox(void *p, void (*fn)(void *))
{
datum pbox;
pbox = make_opaque(sizeof(void *) * 2, pbox_mtab);
pbox[0] = (size_t) p;
pbox[1] = (size_t) fn;
if (fn) install_fz(&pbox);
return (datum) pbox;
}
end
def pbox: sobj:
inline C str <<end
return make_str_init(6, "<pbox>");
end
inline C (finalize.) <<end
((fn_free) rcv[1])((void *) rcv[0]);
return nil;
end
. pbox