3 unsigned oskit_freebsd_cpl
;
5 /* We have to store a reference count somewhere so we
6 * don't free a buffer being referenced in another mbuf.
7 * I just decided to add an extra char to the beginning of
8 * the buffer and store the reference count there. I doubt the ref count
9 * will ever even get close to 0xFF so we should be ok. Remember that
10 * only one thread can ever be inside oskit due to OSKLock so this should
14 void oskit_bufio_addref(void *buf
)
16 unsigned char* fullbuf
= ((unsigned char*)buf
) - sizeof(char);
19 if (fullbuf
[0] == 0xFF)
20 panic("oskit_bufio_addref: ref count overflow");
25 void oskit_bufio_release(void *buf
)
27 unsigned char* fullbuf
= ((unsigned char*)buf
) - sizeof(char);
29 if (--fullbuf
[0] == 0)
32 void* oskit_bufio_create(int len
)
34 unsigned char* fullbuf
= malloc(len
+ sizeof(char), __FILE__
, __LINE__
);
40 return (void*)(fullbuf
+ sizeof(char));
42 void oskit_bufio_map(void *srcbuf
, void**dstbuf
, int off
, int len
)
46 panic("oskit_bufio_map: offset is non-zero");