PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ ptarray_clone_deep()

POINTARRAY* ptarray_clone_deep ( const POINTARRAY ptarray)

Deep clone a pointarray (also clones serialized pointlist)

Definition at line 634 of file ptarray.c.

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

Referenced by _lwt_AddFaceSplit(), _lwt_EdgeMotionArea(), _lwt_HealEdges(), lwcurvepoly_construct_from_lwpoly(), lwcurvepoly_stroke(), LWGEOM_dump_rings(), lwline_clone_deep(), lwmcurve_stroke(), lwmsurface_stroke(), lwpoly_clone_deep(), lwpoly_from_lwlines(), lwtriangle_from_lwline(), parse_gml_coord(), parse_gml_pos(), parse_gml_poslist(), parse_kml_coordinates(), and ptarray_remove_repeated_points_minpoints().

635 {
636  POINTARRAY *out = lwalloc(sizeof(POINTARRAY));
637 
638  LWDEBUG(3, "ptarray_clone_deep called.");
639 
640  out->flags = in->flags;
641  out->npoints = in->npoints;
642  out->maxpoints = in->npoints;
643 
644  FLAGS_SET_READONLY(out->flags, 0);
645 
646  if (!in->npoints)
647  {
648  // Avoid calling lwalloc of 0 bytes
649  out->serialized_pointlist = NULL;
650  }
651  else
652  {
653  size_t size = in->npoints * ptarray_point_size(in);
654  out->serialized_pointlist = lwalloc(size);
655  memcpy(out->serialized_pointlist, in->serialized_pointlist, size);
656  }
657 
658  return out;
659 }
uint8_t * serialized_pointlist
Definition: liblwgeom.h:365
int ptarray_point_size(const POINTARRAY *pa)
Definition: ptarray.c:54
int npoints
Definition: liblwgeom.h:370
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
uint8_t flags
Definition: liblwgeom.h:368
int maxpoints
Definition: liblwgeom.h:371
void * lwalloc(size_t size)
Definition: lwutil.c:227
#define FLAGS_SET_READONLY(flags, value)
Definition: liblwgeom.h:149
Here is the call graph for this function:
Here is the caller graph for this function: