Re: Proposed addition of malloc_size_np()



Poul-Henning Kamp wrote:
In message <44247DF1.8000002@xxxxxxxxxxx>, Jason Evans writes:

=== Proposal ===
Add malloc_size_np() to libc, and provide the prototype in malloc_np.h:

size_t
malloc_size_np(const void *ptr);


I'm for the concept, but wonder if it would be smarter to make it

void *
malloc_np(size_t, size_t *)

so we can do it in one go ?

I can see how this would be useful, but I don't think it completely replaces the use case for malloc_size_np(), which can be useful at other times than allocation/deallocation (ex: assertions that detect buffer overflow). Also, if we add malloc_np(), for completeness we should also provide:

void *
calloc_np(size_t size, size_t *size_ceil);

void *
realloc_np(void *ptr, size_t size, size_t *size_ceil);

(Let's ignore posix_memalign() here.)

size_t
free_np(void *ptr);

Given that these functions are essentially the (somewhat higher performance) fusion of two function calls, it isn't clear to me whether it's worth adding several extra functions. Personally, I would use them if they were available, but I'm not sure if they would be broadly useful. Thoughts?

Thanks,
Jason

_______________________________________________
freebsd-arch@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: what is wikipedia talking about
    ... The Void wrote: ... Most of the adult contestants DON'T ... and say that they aren't smarter than a fifth-grader. ...
    (rec.juggling)
  • Re: Proposed addition of malloc_size_np()
    ... In message, Jason Evans writes: ... but wonder if it would be smarter to make it ... Never attribute to malice what can adequately be explained by incompetence. ...
    (freebsd-arch)
  • Re: Proposed addition of malloc_size_np()
    ... but wonder if it would be smarter to make it ... piece of memory that has been passed to it. ... Peter Jeremy ...
    (freebsd-arch)
  • Re: [New Video] Erin Stephens
    ... The Void wrote: ... <snip snafu'd rate it url> ... Bugger! ... sig's smarter than I am too, ...
    (rec.juggling)
  • Re: dev_lock() question
    ... On Thursday 29 September 2005 03:36 pm, Poul-Henning Kamp wrote: ... Actually, mutexes won't work until after mutex_initanyway, so it had better ... To unsubscribe, ...
    (freebsd-hackers)