PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ ptarray_clone_deep()

POINTARRAY* ptarray_clone_deep ( const POINTARRAY ptarray)

Deep clone a pointarray (also clones serialized pointlist)

Definition at line 628 of file ptarray.c.

629 {
630  POINTARRAY *out = lwalloc(sizeof(POINTARRAY));
631 
632  LWDEBUG(3, "ptarray_clone_deep called.");
633 
634  out->flags = in->flags;
635  out->npoints = in->npoints;
636  out->maxpoints = in->npoints;
637 
638  FLAGS_SET_READONLY(out->flags, 0);
639 
640  if (!in->npoints)
641  {
642  // Avoid calling lwalloc of 0 bytes
643  out->serialized_pointlist = NULL;
644  }
645  else
646  {
647  size_t size = in->npoints * ptarray_point_size(in);
648  out->serialized_pointlist = lwalloc(size);
649  memcpy(out->serialized_pointlist, in->serialized_pointlist, size);
650  }
651 
652  return out;
653 }
void * lwalloc(size_t size)
Definition: lwutil.c:229
#define FLAGS_SET_READONLY(flags, value)
Definition: liblwgeom.h:150
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
size_t ptarray_point_size(const POINTARRAY *pa)
Definition: ptarray.c:54
uint32_t maxpoints
Definition: liblwgeom.h:375
uint32_t npoints
Definition: liblwgeom.h:374
uint8_t * serialized_pointlist
Definition: liblwgeom.h:369
uint8_t flags
Definition: liblwgeom.h:372

References POINTARRAY::flags, FLAGS_SET_READONLY, lwalloc(), LWDEBUG, POINTARRAY::maxpoints, POINTARRAY::npoints, ptarray_point_size(), and POINTARRAY::serialized_pointlist.

Referenced by _lwt_HealEdges(), _lwt_MakeRingShell(), lwcurvepoly_construct_from_lwpoly(), lwcurvepoly_linearize(), LWGEOM_dump_rings(), lwline_clone_deep(), lwmcurve_linearize(), lwmsurface_linearize(), lwpoly_clone_deep(), lwpoly_from_lwlines(), lwtriangle_from_lwline(), parse_kml_coordinates(), and ptarray_remove_repeated_points_minpoints().

Here is the call graph for this function:
Here is the caller graph for this function: