|
@@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
25
|
25
|
#include <ipxe/io.h>
|
26
|
26
|
#include <ipxe/list.h>
|
27
|
27
|
#include <ipxe/init.h>
|
|
28
|
+#include <ipxe/refcnt.h>
|
28
|
29
|
#include <ipxe/malloc.h>
|
29
|
30
|
|
30
|
31
|
/** @file
|
|
@@ -35,10 +36,21 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
35
|
36
|
|
36
|
37
|
/** A free block of memory */
|
37
|
38
|
struct memory_block {
|
38
|
|
- /** List of free blocks */
|
39
|
|
- struct list_head list;
|
40
|
39
|
/** Size of this block */
|
41
|
40
|
size_t size;
|
|
41
|
+ /** Padding
|
|
42
|
+ *
|
|
43
|
+ * This padding exists to cover the "count" field of a
|
|
44
|
+ * reference counter, in the common case where a reference
|
|
45
|
+ * counter is the first element of a dynamically-allocated
|
|
46
|
+ * object. It avoids clobbering the "count" field as soon as
|
|
47
|
+ * the memory is freed, and so allows for the possibility of
|
|
48
|
+ * detecting reference counting errors.
|
|
49
|
+ */
|
|
50
|
+ char pad[ offsetof ( struct refcnt, count ) +
|
|
51
|
+ sizeof ( ( ( struct refcnt * ) NULL )->count ) ];
|
|
52
|
+ /** List of free blocks */
|
|
53
|
+ struct list_head list;
|
42
|
54
|
};
|
43
|
55
|
|
44
|
56
|
#define MIN_MEMBLOCK_SIZE \
|