gcc/testsuite/gcc.dg/analyzer/pr94858-2.c
raw| 1 | #include <stdlib.h> |
| 2 | |
| 3 | typedef short hashNx; |
| 4 | |
| 5 | typedef struct hashSt { |
| 6 | hashNx *hs_index; |
| 7 | int hs_used; |
| 8 | int hs_slots; |
| 9 | } hashSt; |
| 10 | |
| 11 | int test (hashSt *td, int slots) |
| 12 | { |
| 13 | hashNx *index; |
| 14 | |
| 15 | index = malloc((size_t)slots * sizeof(hashNx)); |
| 16 | if (index == NULL) |
| 17 | return 0; |
| 18 | td->hs_index = index; |
| 19 | td->hs_slots = slots; |
| 20 | |
| 21 | for (slots = td->hs_slots, index = td->hs_index; --slots >= 0;) |
| 22 | *index++ = -1; |
| 23 | |
| 24 | return 1; |
| 25 | } |