|
@@ -17,7 +17,7 @@
|
17
|
17
|
*/
|
18
|
18
|
|
19
|
19
|
#include <stdint.h>
|
20
|
|
-#include <gpxe/malloc.h>
|
|
20
|
+#include <malloc.h>
|
21
|
21
|
#include <gpxe/pkbuff.h>
|
22
|
22
|
|
23
|
23
|
/** @file
|
|
@@ -31,35 +31,24 @@
|
31
|
31
|
*
|
32
|
32
|
* @v len Required length of buffer
|
33
|
33
|
* @ret pkb Packet buffer, or NULL if none available
|
34
|
|
- *
|
35
|
|
- * The packet buffer will be aligned as per gmalloc().
|
36
|
34
|
*/
|
37
|
35
|
struct pk_buff * alloc_pkb ( size_t len ) {
|
38
|
36
|
struct pk_buff *pkb = NULL;
|
39
|
|
- void *data;
|
40
|
37
|
|
41
|
|
- /* Align buffer length */
|
42
|
|
- len = ( len + __alignof__ ( *pkb ) - 1 ) & ~ __alignof__ ( *pkb );
|
43
|
|
-
|
44
|
38
|
/* Allocate memory for buffer plus descriptor */
|
45
|
|
- data = gmalloc ( len + sizeof ( *pkb ) );
|
46
|
|
- if ( ! data )
|
47
|
|
- return NULL;
|
48
|
|
-
|
49
|
|
- pkb = ( struct pk_buff * ) ( data + len );
|
50
|
|
- pkb->head = pkb->data = pkb->tail = data;
|
51
|
|
- pkb->end = pkb;
|
|
39
|
+ pkb = malloc ( sizeof ( *pkb ) + len );
|
|
40
|
+ if ( pkb ) {
|
|
41
|
+ pkb->head = pkb->data = pkb->tail = ( void * ) ( pkb + 1 );
|
|
42
|
+ pkb->end = pkb->head + len;
|
|
43
|
+ }
|
52
|
44
|
return pkb;
|
53
|
45
|
}
|
54
|
46
|
|
55
|
47
|
/**
|
56
|
48
|
* Free packet buffer
|
57
|
49
|
*
|
58
|
|
- * @v pkb Packet buffer
|
|
50
|
+ * @v pkb Packet buffer, or NULL
|
59
|
51
|
*/
|
60
|
52
|
void free_pkb ( struct pk_buff *pkb ) {
|
61
|
|
- if ( pkb ) {
|
62
|
|
- gfree ( pkb->head,
|
63
|
|
- ( pkb->end - pkb->head ) + sizeof ( *pkb ) );
|
64
|
|
- }
|
|
53
|
+ free ( pkb );
|
65
|
54
|
}
|