(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
analyzer/
pr94858-1.c
       1  /* { dg-additional-options "-Wno-analyzer-too-complex" } */
       2  
       3  #include <stdlib.h>
       4  
       5  typedef short hashNx;
       6  
       7  typedef struct hashSt {
       8    hashNx *hs_index;
       9    int hs_used;
      10    int hs_slots;
      11  } hashSt;
      12  
      13  void hashEmpty(hashSt *td);
      14  
      15  int hashAlloc(hashSt *td, int slots) {
      16    hashNx *index;
      17  
      18    if (slots > td->hs_slots) {
      19      if (td->hs_index != NULL)
      20        index = realloc(td->hs_index, (size_t)slots * sizeof(hashNx));
      21      else
      22        index = malloc((size_t)slots * sizeof(hashNx));
      23  
      24      if (index == NULL)
      25        return 0;
      26  
      27      td->hs_index = index;
      28      td->hs_slots = slots;
      29    }
      30  
      31    hashEmpty(td);
      32  
      33    return 1;
      34  }
      35  
      36  void hashEmpty(hashSt *td) {
      37    hashNx *index;
      38    int slots;
      39  
      40    for (slots = td->hs_slots, index = td->hs_index; --slots >= 0;)
      41      *index++ = -1;
      42  
      43    td->hs_used = 0;
      44  }