On May 5, 2014, at 3:21 PM, David Chisnall <thera...@freebsd.org> wrote:

> On 5 May 2014, at 20:49, Pedro Giffuni <p...@freebsd.org> wrote:
> 
>> Yes, but I reverted it because there are other ways to check for overflows 
>> without the performance hit.
> 
> Do we have a good reusable routine for doing this somewhere?  Clang and gcc 
> both have some idiom recognisers that try to spot when people are attempting 
> to do this.  Clang also has a builtin, which would be good to use when 
> available.  Overflow checking is very cheap on modern CPUs (add, branch on 
> carry), so it would be nice if we could start looking for this malloc() and 
> realloc() pattern and replacing the multiply with something that checks for 
> the error.

reallocf():
     The reallocf() function is identical to the realloc() function, except
     that it will free the passed pointer when the requested memory cannot be
     allocated.  This is a FreeBSD specific API designed to ease the problems
     with traditional coding styles for realloc() causing memory leaks in
     libraries.
...
     The reallocf() function first appeared in FreeBSD 3.0.

Warner
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to