mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
ng_pktbuf: only duplicate header
This commit is contained in:
parent
85bd69314c
commit
9cea4b6618
@ -30,6 +30,9 @@
|
|||||||
|
|
||||||
#include "_pktbuf_internal.h"
|
#include "_pktbuf_internal.h"
|
||||||
|
|
||||||
|
#define ENABLE_DEBUG (0)
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
static mutex_t _pktbuf_mutex = MUTEX_INIT;
|
static mutex_t _pktbuf_mutex = MUTEX_INIT;
|
||||||
|
|
||||||
/* internal ng_pktbuf functions */
|
/* internal ng_pktbuf functions */
|
||||||
@ -249,28 +252,12 @@ static ng_pktsnip_t *_pktbuf_duplicate(const ng_pktsnip_t *pkt)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEBUG("pktbuf: copying %u byte from %p to %p\n", (unsigned)pkt->size,
|
||||||
|
pkt->data, res->data);
|
||||||
memcpy(res->data, pkt->data, pkt->size);
|
memcpy(res->data, pkt->data, pkt->size);
|
||||||
res->type = pkt->type;
|
res->type = pkt->type;
|
||||||
|
res->next = pkt->next;
|
||||||
while (pkt->next) {
|
DEBUG("pktbuf: set res->next to %p", (void *)pkt->next);
|
||||||
ng_pktsnip_t *hdr = NULL;
|
|
||||||
|
|
||||||
pkt = pkt->next;
|
|
||||||
hdr = _pktbuf_add_unsafe(res, pkt->data, pkt->size, pkt->type);
|
|
||||||
|
|
||||||
if (hdr == NULL) {
|
|
||||||
do {
|
|
||||||
ng_pktsnip_t *next = res->next;
|
|
||||||
|
|
||||||
_pktbuf_internal_free(res->data);
|
|
||||||
_pktbuf_internal_free(res);
|
|
||||||
|
|
||||||
res = next;
|
|
||||||
} while (res);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user