summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2006-04-25 14:04:07 +0200
committerMichael Brown2006-04-25 14:04:07 +0200
commit00a1de964d35598aec89767b2c0942515d9bced6 (patch)
tree286171e112db3f5b416d66193f47299256256169
parentFixed erroneous comparison (diff)
downloadipxe-00a1de964d35598aec89767b2c0942515d9bced6.tar.gz
ipxe-00a1de964d35598aec89767b2c0942515d9bced6.tar.xz
ipxe-00a1de964d35598aec89767b2c0942515d9bced6.zip
Update to use POSIX-like API.
-rw-r--r--src/net/pkbuff.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/src/net/pkbuff.c b/src/net/pkbuff.c
index ec09ab1be..b9b6709bc 100644
--- a/src/net/pkbuff.c
+++ b/src/net/pkbuff.c
@@ -17,7 +17,7 @@
*/
#include <stdint.h>
-#include <gpxe/malloc.h>
+#include <malloc.h>
#include <gpxe/pkbuff.h>
/** @file
@@ -31,35 +31,24 @@
*
* @v len Required length of buffer
* @ret pkb Packet buffer, or NULL if none available
- *
- * The packet buffer will be aligned as per gmalloc().
*/
struct pk_buff * alloc_pkb ( size_t len ) {
struct pk_buff *pkb = NULL;
- void *data;
- /* Align buffer length */
- len = ( len + __alignof__ ( *pkb ) - 1 ) & ~ __alignof__ ( *pkb );
-
/* Allocate memory for buffer plus descriptor */
- data = gmalloc ( len + sizeof ( *pkb ) );
- if ( ! data )
- return NULL;
-
- pkb = ( struct pk_buff * ) ( data + len );
- pkb->head = pkb->data = pkb->tail = data;
- pkb->end = pkb;
+ pkb = malloc ( sizeof ( *pkb ) + len );
+ if ( pkb ) {
+ pkb->head = pkb->data = pkb->tail = ( void * ) ( pkb + 1 );
+ pkb->end = pkb->head + len;
+ }
return pkb;
}
/**
* Free packet buffer
*
- * @v pkb Packet buffer
+ * @v pkb Packet buffer, or NULL
*/
void free_pkb ( struct pk_buff *pkb ) {
- if ( pkb ) {
- gfree ( pkb->head,
- ( pkb->end - pkb->head ) + sizeof ( *pkb ) );
- }
+ free ( pkb );
}