Re: realloc in kernel

From: kernel@kvack.org
Date: Tue May 16 2000 - 15:04:29 EST


On Tue, 16 May 2000, Lee Chin wrote:

> Hello,
> Is there a realloc in the kernel? Basically, I need to realloc kmalloced
> pointers. Is there such an API? I tried to find one but could not.

realloc is such an incredibly good idea that we don't have it in the
kernel. Seriously, realloc has significant problems when you try to
factor in such issues as SMP correctness, reasonable latency and memory
fragmentation.

> If not, what is the best way to implement my own?

Use a different data structure. Because it is not guarenteed that you
will be able to allocate more than a page of kernel memory contiguously,
you may need to be explicitely aware of the limitation in your code
anyways. One possibility is to use a structure like ext2 -- serveral
direct pointers, then an indirect pointer, then a double indirect....
That's if the data will need to be access randomly. If you only care
about linear access, make use of the functions in linux/list.h. Hope this
helps,

                -ben

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue May 23 2000 - 21:00:11 EST