linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: krealloc()
@ 2004-01-11  8:37 Manfred Spraul
  0 siblings, 0 replies; 2+ messages in thread
From: Manfred Spraul @ 2004-01-11  8:37 UTC (permalink / raw)
  To: john moser; +Cc: linux-kernel

John Moser wrote:

>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.

>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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* krealloc()
@ 2004-01-11  4:42 john moser
  0 siblings, 0 replies; 2+ messages in thread
From: john moser @ 2004-01-11  4:42 UTC (permalink / raw)
  To: linux-kernel

Why is there no krealloc()?  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.  realloc() is usually:

void *realloc(void *block, size_t size);

I'm thinking krealloc would be the same, since we'd have the old GFP_* flags and
the old size:

void *krealloc(void *block, size_t size);

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.

I have nowhere near the skill or experience needed to impliment any sort of
krealloc(), so for now I'm going to have to do bad hacks in my code.  Can someone
please impliment a krealloc() by 2.6.2?  Or at least slate it for SOME time in the
future, if not immediately now.

_____________________________________________________________
Linux.Net -->Open Source to everyone
Powered by Linare Corporation
http://www.linare.com/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-01-11  8:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-11  8:37 krealloc() Manfred Spraul
  -- strict thread matches above, loose matches on Subject: below --
2004-01-11  4:42 krealloc() john moser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).