PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ array_range()

static int array_range ( int  min,
int  max,
int  step,
int **  range,
uint32_t *  len 
)
static

Definition at line 96 of file raster2pgsql.c.

96  {
97  int i = 0;
98  int j = 0;
99 
100  step = abs(step);
101  *len = (uint32_t) ((abs(max - min) + 1 + (step / 2)) / step);
102  *range = rtalloc(sizeof(int) * *len);
103 
104  if (min < max) {
105  for (i = min, j = 0; i <= max; i += step, j++)
106  (*range)[j] = i;
107  }
108  else if (max < min) {
109  if (step > 0) step *= -1;
110  for (i = min, j = 0; i >= max; i += step, j++)
111  (*range)[j] = i;
112  }
113  else if (min == max) {
114  (*range)[0] = min;
115  }
116  else {
117  *len = 0;
118  *range = NULL;
119  return 0;
120  }
121 
122  return 1;
123 }
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171

References rtalloc().

Here is the call graph for this function: