[mapserver-commits] r11753 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Mon May 23 11:06:31 EDT 2011


Author: warmerdam
Date: 2011-05-23 08:06:31 -0700 (Mon, 23 May 2011)
New Revision: 11753

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/maplayer.c
Log:
ensure msLayerSetProcessingKey() supports setting a NULL value to clear an entry

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2011-05-23 07:46:31 UTC (rev 11752)
+++ trunk/mapserver/HISTORY.TXT	2011-05-23 15:06:31 UTC (rev 11753)
@@ -15,6 +15,9 @@
 Current Version (SVN trunk, 6.1-dev, future 6.2): 
 ------------------------------------------------- 
 
+- Ensure msLayerSetProcessingKey() supports setting a NULL value to clear
+  a processing key. 
+
 - Write SYMBOLSET/END tags when saving a symbol file (#3885)
 
 - Make java threadtests work again (#3887)

Modified: trunk/mapserver/maplayer.c
===================================================================
--- trunk/mapserver/maplayer.c	2011-05-23 07:46:31 UTC (rev 11752)
+++ trunk/mapserver/maplayer.c	2011-05-23 15:06:31 UTC (rev 11753)
@@ -708,27 +708,44 @@
 {
     int len = strlen(key);
     int i;
-    char *directive;
+    char *directive = NULL;
 
-    directive = (char *) msSmallMalloc(strlen(key)+strlen(value)+2);
-    sprintf( directive, "%s=%s", key, value );
+    if( value != NULL )
+    {
+        directive = (char *) msSmallMalloc(strlen(key)+strlen(value)+2);
+        sprintf( directive, "%s=%s", key, value );
+    }
 
     for( i = 0; i < layer->numprocessing; i++ )
     {
-        /* If the key is found, replace it */
         if( strncasecmp( key, layer->processing[i], len ) == 0 
             && layer->processing[i][len] == '=' )
         {
             free( layer->processing[i] );
-            layer->processing[i] = directive;
+
+            /* 
+            ** Either replace the existing entry with a new one or
+            ** clear the entry.
+            */
+            if( directive != NULL )
+                layer->processing[i] = directive;
+            else
+            {
+                layer->processing[i] = layer->processing[layer->numprocessing-1];
+                layer->processing[layer->numprocessing-1] = NULL;
+                layer->numprocessing--;
+            }
             return;
         }
     }
 
     /* otherwise add the directive at the end. */
 
-    msLayerAddProcessing( layer, directive );
-    free( directive );
+    if( directive != NULL )
+    {
+        msLayerAddProcessing( layer, directive );
+        free( directive );
+    }
 }
 
 void msLayerAddProcessing( layerObj *layer, const char *directive )



More information about the mapserver-commits mailing list