diff options
author | Alfred M. Szmidt <ams@gnu.org> | 2004-12-01 06:10:11 +0000 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gnu.org> | 2009-06-18 00:15:26 +0200 |
commit | 8f95dc8729437a6546a3777106f64d1c671d8ac3 (patch) | |
tree | 806d93a10c23bc2eda42628ba3fcbd29009b8a48 /kern | |
parent | 7e2c3175d713af0d7ce14182fc188a24df176d36 (diff) |
2004-09-07 Neal H. Walfield <neal@cs.uml.edu>
* linux/dev/glue/block.c (__brelse): Unconditionally kfree BH.
(getblk): Unconditionally kalloc BH.
* kern/kalloc.c [!NDEBUG] (kalloc_init_called): New static
variable.
(kalloc_init): Assert that kalloc_init_called is zero.
[! NDEBUG] Set kalloc_init_called to 1 on success.
(kalloc): Assert that kalloc_init_called is non-zero.
(kget): Likewise.
(kfree): Likewise.
Diffstat (limited to 'kern')
-rw-r--r-- | kern/kalloc.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/kern/kalloc.c b/kern/kalloc.c index 5390139..24dfe68 100644 --- a/kern/kalloc.c +++ b/kern/kalloc.c @@ -106,12 +106,18 @@ unsigned long k_zone_max[16] = { * This initializes all of the zones. */ +#ifndef NDEBUG +static int kalloc_init_called; +#endif + void kalloc_init() { vm_offset_t min, max; vm_size_t size; register int i; + assert (! kalloc_init_called); + kalloc_map = kmem_suballoc(kernel_map, &min, &max, kalloc_map_size, FALSE); @@ -142,6 +148,10 @@ void kalloc_init() size >= PAGE_SIZE ? ZONE_COLLECTABLE : 0, k_zone_name[i]); } + +#ifndef NDEBUG + kalloc_init_called = 1; +#endif } vm_offset_t kalloc(size) @@ -153,6 +163,8 @@ vm_offset_t kalloc(size) /* compute the size of the block that we will actually allocate */ + assert (kalloc_init_called); + allocsize = size; if (size < kalloc_max) { allocsize = MINSIZE; @@ -185,6 +197,8 @@ vm_offset_t kget(size) register vm_size_t allocsize; vm_offset_t addr; + assert (kalloc_init_called); + /* compute the size of the block that we will actually allocate */ allocsize = size; @@ -219,6 +233,8 @@ kfree(data, size) register int zindex; register vm_size_t freesize; + assert (kalloc_init_called); + freesize = size; if (size < kalloc_max) { freesize = MINSIZE; |