Displaying 1 result from an estimated 1 matches for "malloc_array_1".
Did you mean:
malloc_array_2
2012 Aug 22
1
[LLVMdev] RFC: optimizing integer overflow checks
...ntation of two passes that complement -instcombine. They recognize common checking patterns and rewrite them using overflow intrinsics.
https://gist.github.com/3429064
https://gist.github.com/3429069
Here goes an example.
$ cat t.c
#include <stdlib.h>
#include <stdint.h>
void *malloc_array_1(size_t n, size_t size)
{
if (size && n > SIZE_MAX / size)
return NULL;
return malloc(n * size);
}
void *malloc_array_2(size_t n, size_t size)
{
size_t bytes = n * size;
if (size && n != bytes / size)
return NULL;...