Re: sizeof([ALLOCATED MEMORY])
- From: "Ion Gaztañaga" <igaztanaga@xxxxxxxxx>
- Date: 16 May 2006 12:09:30 -0700
Not necessarily. Consider the hypothetical "one time use"
allocater. realloc need only allocate a new chunk of the
appropriate size and copy the old over. It doesn't need to know
the size of the old, even for the copying if it can detect 'the
end' by some other means, analogous to encountering EOF.
For the extended malloc interface we should see how malloc is
implemented to see if size information is there and is fast to obtain.
I don't know any malloc implementation that does not store the size. So
if the size is there in all known implementations, it's logical to
propose new functions. If all known malloc implementations (check every
C library out there to check this) store the size, I think that we
should use that information to get better performance and less memory
use.
Maybe obtaining the size is not constant time in the "one time use"
allocator and you must do something similar to "strlen()", but let's be
practical: there is not such allocator in the real world, and I doubt
it will ever exist.
So let's asume that the size information is there and is very cheap to
obtain. Now we can discuss if proposed functions improve performance or
not, or they are useful enough enough to include them in the standard.
I can understand that you can think that those advanced reallocation
functions are not useful because you might never need them for general
purpose C programming. I think that memory reallocation is a common
pattern for a lot of C programs, and that there is an easy way to
improve their performance through these functions.
Regards,
Ion
.
- Follow-Ups:
- Re: sizeof([ALLOCATED MEMORY])
- From: ais523
- Re: sizeof([ALLOCATED MEMORY])
- From: Stephen Sprunk
- Re: sizeof([ALLOCATED MEMORY])
- References:
- sizeof([ALLOCATED MEMORY])
- From: ballpointpenthief
- Re: sizeof([ALLOCATED MEMORY])
- From: Richard Heathfield
- Re: sizeof([ALLOCATED MEMORY])
- From: Howard Hinnant
- Re: sizeof([ALLOCATED MEMORY])
- From: "Nils O. Selåsdal"
- Re: sizeof([ALLOCATED MEMORY])
- From: Howard Hinnant
- Re: sizeof([ALLOCATED MEMORY])
- From: Stephen Sprunk
- Re: sizeof([ALLOCATED MEMORY])
- From: Howard Hinnant
- Re: sizeof([ALLOCATED MEMORY])
- From: Keith Thompson
- Re: sizeof([ALLOCATED MEMORY])
- From: Robert Latest
- Re: sizeof([ALLOCATED MEMORY])
- From: Howard Hinnant
- Re: sizeof([ALLOCATED MEMORY])
- From: Robert Latest
- Re: sizeof([ALLOCATED MEMORY])
- From: Howard Hinnant
- Re: sizeof([ALLOCATED MEMORY])
- From: Robert Latest
- Re: sizeof([ALLOCATED MEMORY])
- From: Keith Thompson
- Re: sizeof([ALLOCATED MEMORY])
- From: Howard Hinnant
- Re: sizeof([ALLOCATED MEMORY])
- From: CBFalconer
- sizeof([ALLOCATED MEMORY])
- Prev by Date: Re: diff between sprintf() and fprintf()
- Next by Date: Re: pointer q
- Previous by thread: Re: sizeof([ALLOCATED MEMORY])
- Next by thread: Re: sizeof([ALLOCATED MEMORY])
- Index(es):
Relevant Pages
|