Debian Codegraph @

gcc/testsuite/c-c++-common/analyzer/realloc-pr110014.c

raw
1 void *realloc (void *, unsigned long)
2 __attribute__((__nothrow__, __leaf__))
3 __attribute__((__warn_unused_result__)) __attribute__((__alloc_size__ (2)));
4
5 long *
6 slurp (long *buffer, unsigned long file_size)
7 {
8 unsigned long cc;
9 if (!__builtin_add_overflow (file_size - file_size % sizeof (long),
10 2 * sizeof (long), &cc))
11 buffer = (long *) realloc (buffer, cc);
12 return buffer;
13 }
14
15 long *
16 slurp1 (long *buffer, unsigned long file_size)
17 {
18 return (long *) realloc (buffer, file_size - file_size % sizeof (long));
19 }
20
21 long *
22 slurp2 (long *buffer, unsigned long file_size)
23 {
24 return (long *) realloc (buffer, (file_size / sizeof (long)) * sizeof (long));
25 }