[mapserver-commits] r11452 - in trunk/mapserver: . mapscript/php mapscript/swiginc

svn at osgeo.org svn at osgeo.org
Mon Apr 4 09:25:43 EDT 2011


Author: aboudreault
Date: 2011-04-04 06:25:43 -0700 (Mon, 04 Apr 2011)
New Revision: 11452

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/cgiutil.c
   trunk/mapserver/mapscript/php/mapscript_i.c
   trunk/mapserver/mapscript/swiginc/owsrequest.i
   trunk/mapserver/mapserv.c
   trunk/mapserver/maptemplate.c
   trunk/mapserver/mapwms.c
Log:
Move allocation of cgiRequestObj paramNames/Values to msAllocCgiObj() (#1888)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2011-04-03 17:06:18 UTC (rev 11451)
+++ trunk/mapserver/HISTORY.TXT	2011-04-04 13:25:43 UTC (rev 11452)
@@ -15,6 +15,8 @@
 Current Version (SVN trunk): 
 ---------------------------- 
 
+- Move allocation of cgiRequestObj paramNames/Values to msAllocCgiObj() (#1888)
+
 - Add support for simple aggregates for the cluster layer attributes (#3700)
 
 - Improved error reporting in msSaveImage() (#3733)

Modified: trunk/mapserver/cgiutil.c
===================================================================
--- trunk/mapserver/cgiutil.c	2011-04-03 17:06:18 UTC (rev 11451)
+++ trunk/mapserver/cgiutil.c	2011-04-04 13:25:43 UTC (rev 11452)
@@ -480,8 +480,8 @@
   if(!request)
     return NULL;
 
-  request->ParamNames = NULL;
-  request->ParamValues = NULL;
+  request->ParamNames = (char **) msSmallMalloc(MS_DEFAULT_CGI_PARAMS*sizeof(char*));
+  request->ParamValues = (char **) msSmallMalloc(MS_DEFAULT_CGI_PARAMS*sizeof(char*));
   request->NumParams = 0;
   request->type = -1;
   request->contenttype = NULL;

Modified: trunk/mapserver/mapscript/php/mapscript_i.c
===================================================================
--- trunk/mapserver/mapscript/php/mapscript_i.c	2011-04-03 17:06:18 UTC (rev 11451)
+++ trunk/mapserver/mapscript/php/mapscript_i.c	2011-04-04 13:25:43 UTC (rev 11452)
@@ -1424,9 +1424,6 @@
     cgiRequestObj *request;
     request = msAllocCgiObj();
 
-    request->ParamNames = (char **) malloc(MS_DEFAULT_CGI_PARAMS*sizeof(char*));
-    request->ParamValues = (char **) malloc(MS_DEFAULT_CGI_PARAMS*sizeof(char*));
-
     return request;
 }
 
@@ -1493,8 +1490,6 @@
 }
 void cgirequestObj_destroy(cgiRequestObj *self)
 {
-    msFreeCharArray(self->ParamNames, self->NumParams);
-    msFreeCharArray(self->ParamValues, self->NumParams);
     free(self);
 }
 

Modified: trunk/mapserver/mapscript/swiginc/owsrequest.i
===================================================================
--- trunk/mapserver/mapscript/swiginc/owsrequest.i	2011-04-03 17:06:18 UTC (rev 11451)
+++ trunk/mapserver/mapscript/swiginc/owsrequest.i	2011-04-04 13:25:43 UTC (rev 11452)
@@ -67,12 +67,6 @@
             return NULL;
         }
         
-        request->ParamNames = (char **) malloc(MS_DEFAULT_CGI_PARAMS*sizeof(char*));
-        request->ParamValues = (char **) malloc(MS_DEFAULT_CGI_PARAMS*sizeof(char*));
-        if (request->ParamNames==NULL || request->ParamValues==NULL) {
-	        msSetError(MS_MEMERR, NULL, "OWSRequest()");
-            return NULL;
-        }
         return request;
     }
 
@@ -82,8 +76,6 @@
     ~cgiRequestObj(void)
 #endif
     {
-        msFreeCharArray(self->ParamNames, self->NumParams);
-        msFreeCharArray(self->ParamValues, self->NumParams);
         free(self);
     }
 

Modified: trunk/mapserver/mapserv.c
===================================================================
--- trunk/mapserver/mapserv.c	2011-04-03 17:06:18 UTC (rev 11451)
+++ trunk/mapserver/mapserv.c	2011-04-04 13:25:43 UTC (rev 11452)
@@ -1186,13 +1186,6 @@
     mapserv = msAllocMapServObj();
     mapserv->sendheaders = sendheaders; /* override the default if necessary (via command line -nh switch) */
 
-    mapserv->request->ParamNames = (char **) msSmallMalloc(MS_DEFAULT_CGI_PARAMS*sizeof(char*));
-    mapserv->request->ParamValues = (char **) msSmallMalloc(MS_DEFAULT_CGI_PARAMS*sizeof(char*));
-    if(mapserv->request->ParamNames==NULL || mapserv->request->ParamValues==NULL) {
-      msSetError(MS_MEMERR, NULL, "mapserv()");
-      writeError();
-    }
-
     mapserv->request->NumParams = loadParams(mapserv->request, NULL, NULL, 0, NULL);
     if( mapserv->request->NumParams == -1 ) {
 #ifdef USE_FASTCGI

Modified: trunk/mapserver/maptemplate.c
===================================================================
--- trunk/mapserver/maptemplate.c	2011-04-03 17:06:18 UTC (rev 11451)
+++ trunk/mapserver/maptemplate.c	2011-04-04 13:25:43 UTC (rev 11452)
@@ -4670,6 +4670,8 @@
     mapserv->Mode = BROWSE;
 
     if(names && values && numentries > 0) {
+      msFreeCharArray(mapserv->request->ParamNames, mapserv->request->NumParams);
+      msFreeCharArray(mapserv->request->ParamValues, mapserv->request->NumParams);
       mapserv->request->ParamNames = names;
       mapserv->request->ParamValues = values;
       mapserv->request->NumParams = numentries;    
@@ -4721,6 +4723,8 @@
     mapserv->Mode = BROWSE;
 
     if(names && values && numentries > 0) {
+      msFreeCharArray(mapserv->request->ParamNames, mapserv->request->NumParams);
+      msFreeCharArray(mapserv->request->ParamValues, mapserv->request->NumParams);
       mapserv->request->ParamNames = names;
       mapserv->request->ParamValues = values;
       mapserv->request->NumParams = numentries;    
@@ -4756,6 +4760,8 @@
     mapserv->Mode = QUERY;
 
     if(names && values && numentries > 0) {
+      msFreeCharArray(mapserv->request->ParamNames, mapserv->request->NumParams);
+      msFreeCharArray(mapserv->request->ParamValues, mapserv->request->NumParams);
       mapserv->request->ParamNames = names;
       mapserv->request->ParamValues = values;
       mapserv->request->NumParams = numentries;    

Modified: trunk/mapserver/mapwms.c
===================================================================
--- trunk/mapserver/mapwms.c	2011-04-03 17:06:18 UTC (rev 11451)
+++ trunk/mapserver/mapwms.c	2011-04-04 13:25:43 UTC (rev 11452)
@@ -3255,6 +3255,8 @@
      msTranslateWMS2Mapserv(names, values, &numentries);
 
      msObj->map = map;
+     msFreeCharArray(msObj->request->ParamNames, msObj->request->NumParams);
+     msFreeCharArray(msObj->request->ParamValues, msObj->request->NumParams);
      msObj->request->ParamNames = names;
      msObj->request->ParamValues = values;
      msObj->Mode = QUERY;



More information about the mapserver-commits mailing list