[mapserver-commits] r12846 - sandbox/sdlime/rfc-77

svn at osgeo.org svn at osgeo.org
Mon Dec 5 08:39:17 EST 2011


Author: sdlime
Date: 2011-12-05 05:39:17 -0800 (Mon, 05 Dec 2011)
New Revision: 12846

Modified:
   sandbox/sdlime/rfc-77/mapfile.c
   sandbox/sdlime/rfc-77/mapprimitive.c
   sandbox/sdlime/rfc-77/mapprimitive.h
   sandbox/sdlime/rfc-77/mapserver.h
Log:
Store things like an individual label point, path and text in a labelObj.

Modified: sandbox/sdlime/rfc-77/mapfile.c
===================================================================
--- sandbox/sdlime/rfc-77/mapfile.c	2011-12-05 12:38:01 UTC (rev 12845)
+++ sandbox/sdlime/rfc-77/mapfile.c	2011-12-05 13:39:17 UTC (rev 12846)
@@ -891,14 +891,7 @@
       break;
     }
     case(TEXT):
-      if(shape->text && shape->numtext > 0)
-        free(shape->text[0]); /* avoid memory leak (could consider allowing multiple TEXT values for inline features) */
-      else {
-        shape->text = (char **) msSmallMalloc(sizeof(char *));
-        shape->numtext = 1;
-      } 
-
-      if(getString(&shape->text[0]) == MS_FAILURE) return(MS_FAILURE);
+      if(getString(&shape->text) == MS_FAILURE) return(MS_FAILURE);
       break;
     case(WKT):
       {
@@ -952,10 +945,7 @@
     fprintf(stream, "\"\n");
   }
 
-  if(feature->text) {
-    for (i=0; i<feature->numtext; i++)
-      writeString(stream, indent, "TEXT", NULL, feature->text[i]);
-  }
+  writeString(stream, indent, "TEXT", NULL, feature->text);
   writeBlockEnd(stream, indent, "FEATURE");
 }
 
@@ -1660,6 +1650,10 @@
     label->bindings[i].index = -1;
   }
 
+  label->annopath = NULL;
+  label->annopoint = NULL;
+  label->annotext = NULL;
+
   return;
 }
 
@@ -1684,6 +1678,9 @@
   for(i=0; i<MS_LABEL_BINDING_LENGTH; i++)
     msFree(label->bindings[i].item);
 
+  /* RFC 77 TODO: free book keeping vars */
+  msFree(label->annotext);
+
   return MS_SUCCESS;
 }
 
@@ -5201,15 +5198,17 @@
 int msFreeLabelCacheSlot(labelCacheSlotObj *cacheslot) {
   int i, j;
 
-  /* free the labels */
+  /* free the labels (labelCacheMemberObj's) */
   if (cacheslot->labels)
     for(i=0; i<cacheslot->numlabels; i++) {
-      msFree(cacheslot->labels[i].text);
       if (cacheslot->labels[i].labelpath)
         msFreeLabelPathObj(cacheslot->labels[i].labelpath);
-      freeLabel(&(cacheslot->labels[i].label));
+
+      for(j=0;j<cacheslot->labels[i].numlabels; j++) freeLabel(&(cacheslot->labels[i].labels[j]));
+
       msFreeShape(cacheslot->labels[i].poly); /* empties the shape */
       msFree(cacheslot->labels[i].poly); /* free's the pointer */
+
       for(j=0;j<cacheslot->labels[i].numstyles; j++) freeStyle(&(cacheslot->labels[i].styles[j]));
       msFree(cacheslot->labels[i].styles);
     }

Modified: sandbox/sdlime/rfc-77/mapprimitive.c
===================================================================
--- sandbox/sdlime/rfc-77/mapprimitive.c	2011-12-05 12:38:01 UTC (rev 12845)
+++ sandbox/sdlime/rfc-77/mapprimitive.c	2011-12-05 13:39:17 UTC (rev 12846)
@@ -106,7 +106,6 @@
 
   /* annotation component */
   shape->text = NULL;
-  shape->numtext = 0;
 
   /* bookkeeping component */
   shape->classindex = 0; /* default class */
@@ -130,12 +129,7 @@
   to->bounds.maxx = from->bounds.maxx;
   to->bounds.maxy = from->bounds.maxy;
 
-  if(from->text) {
-    to->text = (char **)msSmallMalloc(sizeof(char *)*from->numtext);
-    for(i=0; i<from->numtext; i++)
-      to->text[i] = msStrdup(from->text[i]);
-    to->numtext = from->numtext;
-  }
+  if(from->text) to->text = msStrdup(from->text);
 
   to->classindex = from->classindex;
   to->index = from->index;
@@ -166,7 +160,7 @@
 
   if(shape->line) free(shape->line);
   if(shape->values) msFreeCharArray(shape->values, shape->numvalues);
-  if(shape->text) msFreeCharArray(shape->text, shape->numtext);
+  if(shape->text) msFree(shape->text);
   
 #ifdef USE_GEOS
   msGEOSFreeGeometry(shape);

Modified: sandbox/sdlime/rfc-77/mapprimitive.h
===================================================================
--- sandbox/sdlime/rfc-77/mapprimitive.h	2011-12-05 12:38:01 UTC (rev 12845)
+++ sandbox/sdlime/rfc-77/mapprimitive.h	2011-12-05 13:39:17 UTC (rev 12846)
@@ -70,7 +70,7 @@
 #endif
   int numlines;
   int numvalues;
-  int numtext;
+ 
 #ifndef SWIG
   lineObj *line;
   char **values;
@@ -87,7 +87,7 @@
   long index;
   int tileindex;
   int classindex;
-  char **text;
+  char *text;
   
   int scratch;
   int resultindex; /* index within a query result set */

Modified: sandbox/sdlime/rfc-77/mapserver.h
===================================================================
--- sandbox/sdlime/rfc-77/mapserver.h	2011-12-05 12:38:01 UTC (rev 12845)
+++ sandbox/sdlime/rfc-77/mapserver.h	2011-12-05 13:39:17 UTC (rev 12846)
@@ -971,6 +971,11 @@
 #ifndef SWIG
   attributeBindingObj bindings[MS_LABEL_BINDING_LENGTH];
   int numbindings;
+
+  /* book keeping variables- used on a feature-by-feature basis (similar to bindings) */
+  labelPathObj *annopath;
+  pointObj *annopoint;
+  char *annotext;
 #endif
 
 } labelObj;
@@ -1055,7 +1060,6 @@
 %immutable;
 #endif /* SWIG */
 typedef struct {
-  char **text; /* copied from the shapeObj (count should match numlabels) */
   double featuresize;
 
   styleObj *styles; /* copied from the classObj, only present if there is a marker to be drawn */



More information about the mapserver-commits mailing list