Re: Proposed addition of malloc_size_np()
- From: John Baldwin <jhb@xxxxxxxxxxx>
- Date: Mon, 27 Mar 2006 11:10:00 -0500
On Sunday 26 March 2006 13:04, Jason Evans wrote:
Robert Watson wrote:
I wonder if the intuitive objection people are raising is actually with
the name. Since malloc_size() is defined on at least one platform to
return the requested size, maybe a name like malloc_allocated_size() (or
something a bit more compact) would help avoid that confusion, and make
it clear that the consumer is getting back a commitment and not a hint
for future realloc(), etc.
Maybe you're right. We could just call it malloc_usable_size() and be
compatible with Linux.
It would help to know why such a function would be useful. :) Do you have
a specific use-case? If the purpose is for a program to see that it really
as Y >= X bytes when it did malloc(X) so that the program can use Y bytes,
that would seem to only be a source of bugs and complexity. If the program
wants Y bytes, it should malloc(Y). Many folks in the thread seem to think
that this function would be used for a poor-man's realloc() wrapper or
something, and I think such uses would be short-sighted at best. If there
are other uses such as for having a debug malloc wrap the real one, then
that might justify the API, but it is unclear what a useful use of this API
would be.
--
John Baldwin <jhb@xxxxxxxxxxx> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve" = http://www.FreeBSD.org
_______________________________________________
freebsd-arch@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@xxxxxxxxxxx"
- Follow-Ups:
- Re: Proposed addition of malloc_size_np()
- From: Jason Evans
- Re: Proposed addition of malloc_size_np()
- References:
- Proposed addition of malloc_size_np()
- From: Jason Evans
- Re: Proposed addition of malloc_size_np()
- From: Robert Watson
- Re: Proposed addition of malloc_size_np()
- From: Jason Evans
- Proposed addition of malloc_size_np()
- Prev by Date: Re: Proposed addition of malloc_size_np()
- Next by Date: Re: Proposed addition of malloc_size_np()
- Previous by thread: Re: Proposed addition of malloc_size_np()
- Next by thread: Re: Proposed addition of malloc_size_np()
- Index(es):