Skip to contentSkip to conversation

krealloc()

DISCUSSION Manfred Spraul 1 participant 1 message Jan 11, 2004

lore
Share & tools
lore
#0 lore raw
Quoted 4 lines · John Moser

I'm not sure if I should just call mmap() inside the
kernel (any security hazzards or whatnot I should be worried about there?), but it's going to be a pain to resize arrays.

mmap only works for user space memory, not for kernel memory.

Quoted 6 lines

Most realloc() implimentations grow or shrink in place, if possible. If they can't, or if that wasn't how they were coded, they allocate the new block, memcpy() over, then free the old block.

The kmalloc implementation is object based, it cannot grow in place. The only approach is call ksize and check if it fits by chance, otherwise alloc new block and memcpy, then free. Why do you need realloc? What do you want to do? Are you aware that kmalloc is limited to 128 kB, and that large kmallocs (I'd guess: > 16 kB) can fail due to memory fragmentation after long uptimes?

--
Manfred