48 if ((ph = ph_alloc()) == NULL) {
49 fprintf(stderr,
"packetmem_init: ph_alloc failed\n");
69 while (ph != NULL && ph->len < length) {
79 if (ph->len == length) {
83 if (ph_prev == NULL) {
86 ph_prev->next = ph->next;
94 if ((ph_new = ph_alloc()) == NULL) {
95 fprintf(stderr,
"packetmem_alloc: ph_alloc failed\n");
99 ph_new->base = ph->base;
100 ph_new->len = length;
120 while (ph != NULL && ph->next != NULL && ph->next->base < handle->base) {
126 if (ph_prev == NULL) {
127 handle->next = freelist;
130 handle->next = ph_prev->next;
131 ph_prev->next = handle;
135 merge_items(ph_prev);
146 if (ph_prev != NULL) {
148 if (ph_prev->base + ph_prev->len == ph->base) {
150 ph_prev->next = ph->next;
151 ph_prev->len += ph->len;
161 if (ph_next != NULL && ph->base + ph->len == ph_next->base) {
162 ph->len += ph_next->len;
163 ph->next = ph_next->next;
int packetmem_alloc(size_t length, uintptr_t *off, struct packetmem_handle **handle)
void packetmem_free(struct packetmem_handle *handle)