Re: More questions on realloc
- From: Robert Harris <robert.f.harris@xxxxxxxxxxxxxxxx>
- Date: Tue, 29 Nov 2005 17:27:48 GMT
Mark McIntyre wrote:
But realloc doesn't always have to reallocate memory; if you malloc, say, 10 bytes, you may well actually get 32 (or 1024) bytes. Your C library knows how much but you don't, so calling realloc() is often a win over malloc(), memcpy() and free().On Tue, 29 Nov 2005 17:01:17 GMT, in comp.lang.c , "James S. Singleton" <pt109@xxxxxxxxxx> wrote:
My question is, how does realloc know that p points to a memory region
size1 bytes in length?
[snip]
Or, to put it differently, can realloc be implemented with malloc, and no other memory management call?
You'd need memcpy and free. How else can you copy the memory from the
old to the new pointers, and then free the old one?
Robert .
- Follow-Ups:
- Re: More questions on realloc
- From: Mark McIntyre
- Re: More questions on realloc
- References:
- More questions on realloc
- From: James S. Singleton
- Re: More questions on realloc
- From: Mark McIntyre
- More questions on realloc
- Prev by Date: Re: More questions on realloc
- Next by Date: Re: More questions on realloc
- Previous by thread: Re: More questions on realloc
- Next by thread: Re: More questions on realloc
- Index(es):
Relevant Pages
|
|