PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ shuffle()

static void shuffle ( void *  array,
size_t  n,
size_t  size 
)
static

Definition at line 1649 of file liblwgeom/lwgeom_geos.c.

Referenced by lwpoly_to_points().

1649  {
1650  char tmp[size];
1651  char *arr = array;
1652  size_t stride = size;
1653 
1654  if (n > 1) {
1655  size_t i;
1656  for (i = 0; i < n - 1; ++i) {
1657  size_t rnd = (size_t) rand();
1658  size_t j = i + rnd / (RAND_MAX / (n - i) + 1);
1659 
1660  memcpy(tmp, arr + j * stride, size);
1661  memcpy(arr + j * stride, arr + i * stride, size);
1662  memcpy(arr + i * stride, tmp, size);
1663  }
1664  }
1665 }
Here is the caller graph for this function: