Skip to content
Permalink
Browse files

Replace strdup with msStrdup in mapscript files

  • Loading branch information...
geographika
geographika committed Sep 3, 2016
1 parent d3b3948 commit dcb82912316ebffacfdbebd4369417c3dfb2fd53
@@ -322,7 +322,7 @@ PHP_METHOD(labelObj, setBinding)
php_label->label->numbindings--;
}

php_label->label->bindings[bindingId].item = strdup(value);
php_label->label->bindings[bindingId].item = msStrdup(value);
php_label->label->numbindings++;

RETURN_LONG(MS_SUCCESS);
@@ -1506,7 +1506,7 @@ PHP_METHOD(layerObj, setProcessing)
else
php_layer->layer->processing = (char **) realloc(php_layer->layer->processing, sizeof(char*) * (php_layer->layer->numprocessing+1));

php_layer->layer->processing[php_layer->layer->numprocessing-1] = strdup(string);
php_layer->layer->processing[php_layer->layer->numprocessing-1] = msStrdup(string);
php_layer->layer->processing[php_layer->layer->numprocessing] = NULL;

RETURN_LONG(MS_SUCCESS);
@@ -3162,7 +3162,7 @@ PHP_METHOD(mapObj, loadOwsParameters)
php_request = (php_owsrequest_object *) zend_object_store_get_object(zrequest TSRMLS_CC);

if (!version) {
version = strdup("1.1.1");
version = msStrdup("1.1.1");
isZval = 0;
}

@@ -215,7 +215,7 @@ int mapObj_queryByFilter(mapObj* self, char *string)
self->query.type = MS_QUERY_BY_FILTER;
self->query.mode = MS_QUERY_MULTIPLE;

self->query.filter.string = strdup(string);
self->query.filter.string = msStrdup(string);
self->query.filter.type = MS_EXPRESSION;

self->query.rect = self->extent;
@@ -351,7 +351,7 @@ int mapObj_setSymbolSet(mapObj *self,
msInitSymbolSet(&self->symbolset);

// Set symbolset filename
self->symbolset.filename = strdup(szFileName);
self->symbolset.filename = msStrdup(szFileName);

// Symbolset shares same fontset as main mapfile
self->symbolset.fontset = &(self->fontset);
@@ -370,7 +370,7 @@ int mapObj_setFontSet(mapObj *self, char *szFileName)
msInitFontSet(&(self->fontset));

// Set fontset filename
self->fontset.filename = strdup(szFileName);
self->fontset.filename = msStrdup(szFileName);

return msLoadFontSet(&(self->fontset), self);
}
@@ -711,7 +711,7 @@ int layerObj_queryByFilter(layerObj *self, mapObj *map, char *string)
map->query.type = MS_QUERY_BY_FILTER;
map->query.mode = MS_QUERY_MULTIPLE;

map->query.filter.string = strdup(string);
map->query.filter.string = msStrdup(string);
map->query.filter.type = MS_EXPRESSION;

map->query.layer = self->index;
@@ -1551,7 +1551,7 @@ int rectObj_draw(rectObj *self, mapObj *map, layerObj *layer,
shape.classindex = classindex;

if(text && layer->class[classindex]->numlabels > 0) {
shape.text = strdup(text);
shape.text = msStrdup(text);
}

if(MS_SUCCESS != msDrawShape(map, layer, &shape, img, -1, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS)) {
@@ -1837,13 +1837,13 @@ void cgirequestObj_setParameter(cgiRequestObj *self, char *name, char *value)
for (i=0; i<self->NumParams; i++) {
if (strcasecmp(self->ParamNames[i], name) == 0) {
free(self->ParamValues[i]);
self->ParamValues[i] = strdup(value);
self->ParamValues[i] = msStrdup(value);
break;
}
}
if (i == self->NumParams) {
self->ParamNames[self->NumParams] = strdup(name);
self->ParamValues[self->NumParams] = strdup(value);
self->ParamNames[self->NumParams] = msStrdup(name);
self->ParamValues[self->NumParams] = msStrdup(value);
self->NumParams++;
}
}
@@ -1853,8 +1853,8 @@ void cgirequestObj_addParameter(cgiRequestObj *self, char *name, char *value)
if (self->NumParams == MS_DEFAULT_CGI_PARAMS) {
msSetError(MS_CHILDERR, "Maximum number of items, %d, has been reached", "addParameter()", MS_DEFAULT_CGI_PARAMS);
}
self->ParamNames[self->NumParams] = strdup(name);
self->ParamValues[self->NumParams] = strdup(value);
self->ParamNames[self->NumParams] = msStrdup(name);
self->ParamValues[self->NumParams] = msStrdup(value);
self->NumParams++;
}

@@ -221,7 +221,7 @@ static zend_always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isre
convert_to_string(value); \
if (internal) free(internal); \
if (Z_STRVAL_P(value)) \
internal = strdup(Z_STRVAL_P(value)); \
internal = msStrdup(Z_STRVAL_P(value)); \
}

#define IF_SET_LONG(property_name, internal, value) \
@@ -353,7 +353,7 @@ DLEXPORT void php_proj_pj_init(INTERNAL_FUNCTION_PARAMETERS)
(void **)&pParam) != FAILURE) {
convert_to_string((*pParam));
if ((*pParam)->value.str.val != NULL)
papszBuf[i] = strdup((*pParam)->value.str.val);
papszBuf[i] = msStrdup((*pParam)->value.str.val);
}
}
papszBuf[i] = NULL;
@@ -256,7 +256,7 @@ PHP_METHOD(styleObj, __set)
convert_to_string(value);
if (php_style->style->symbolname) free(php_style->style->symbolname);
if (Z_STRVAL_P(value))
php_style->style->symbolname = strdup(Z_STRVAL_P(value));
php_style->style->symbolname = msStrdup(Z_STRVAL_P(value));

/* The parent can be a classObj or a labelCacheMemberObj */
if (Z_OBJCE_P(php_style->parent.val) == mapscript_ce_class) {
@@ -403,7 +403,7 @@ PHP_METHOD(styleObj, setBinding)
php_style->style->numbindings--;
}

php_style->style->bindings[bindingId].item = strdup(value);
php_style->style->bindings[bindingId].item = msStrdup(value);
php_style->style->numbindings++;

RETURN_LONG(MS_SUCCESS);
@@ -94,7 +94,7 @@
self->numbindings--;
}

self->bindings[binding].item = strdup(item);
self->bindings[binding].item = msStrdup(item);
self->numbindings++;

return MS_SUCCESS;
@@ -303,7 +303,7 @@
map->query.type = MS_QUERY_BY_FILTER;
map->query.mode = MS_QUERY_MULTIPLE;

map->query.filter.string = strdup(string);
map->query.filter.string = msStrdup(string);
map->query.filter.type = MS_EXPRESSION;

map->query.layer = self->index;
@@ -168,7 +168,7 @@
else
{
msFree( self->imagetype );
self->imagetype = strdup(imagetype);
self->imagetype = msStrdup(imagetype);
msApplyOutputFormat( &(self->outputformat), format, MS_NOOVERRIDE,
MS_NOOVERRIDE, MS_NOOVERRIDE );
}
@@ -185,7 +185,7 @@
else
{
msFree( self->imagetype );
self->imagetype = strdup(imagetype);
self->imagetype = msStrdup(imagetype);
msApplyOutputFormat( &(self->outputformat), format, MS_NOOVERRIDE,
MS_NOOVERRIDE, MS_NOOVERRIDE );
}
@@ -260,7 +260,7 @@
self->query.type = MS_QUERY_BY_FILTER;
self->query.mode = MS_QUERY_MULTIPLE;

self->query.filter.string = strdup(string);
self->query.filter.string = msStrdup(string);
self->query.filter.type = MS_EXPRESSION;

self->query.rect = self->extent;
@@ -375,7 +375,7 @@
msFreeSymbolSet(&self->symbolset);
msInitSymbolSet(&self->symbolset);

self->symbolset.filename = strdup(szFileName);
self->symbolset.filename = msStrdup(szFileName);

/* Symbolset shares same fontset as main mapfile */
self->symbolset.fontset = &(self->fontset);
@@ -391,7 +391,7 @@
msFreeFontSet(&(self->fontset));
msInitFontSet(&(self->fontset));

self->fontset.filename = strdup(filename);
self->fontset.filename = msStrdup(filename);

return msLoadFontSet(&(self->fontset), self);
}
@@ -64,13 +64,13 @@
void setExtension( const char *extension )
{
msFree( self->extension );
self->extension = strdup(extension);
self->extension = msStrdup(extension);
}

void setMimetype( const char *mimetype )
{
msFree( self->mimetype );
self->mimetype = strdup(mimetype);
self->mimetype = msStrdup(mimetype);
}
#endif

@@ -87,13 +87,13 @@
%newobject getOption;
char *getOption(const char *key, const char *value="")
{
return strdup(msGetOutputFormatOption(self, key, value));
return msStrdup(msGetOutputFormatOption(self, key, value));
}

%newobject getOptionAt;
char* getOptionAt(int i) {
if( i >= 0 && i < self->numformatoptions ) {
return strdup(self->formatoptions[i]);
return msStrdup(self->formatoptions[i]);
}
return NULL;
}
@@ -94,13 +94,13 @@ static char *msGetEnvURL( const char *key, void *thread_context )
for (i=0; i<self->NumParams; i++) {
if (strcasecmp(self->ParamNames[i], name) == 0) {
free(self->ParamValues[i]);
self->ParamValues[i] = strdup(value);
self->ParamValues[i] = msStrdup(value);
break;
}
}
if (i == self->NumParams) {
self->ParamNames[self->NumParams] = strdup(name);
self->ParamValues[self->NumParams] = strdup(value);
self->ParamNames[self->NumParams] = msStrdup(name);
self->ParamValues[self->NumParams] = msStrdup(value);
self->NumParams++;
}
}
@@ -110,8 +110,8 @@ static char *msGetEnvURL( const char *key, void *thread_context )
if (self->NumParams == MS_DEFAULT_CGI_PARAMS) {
msSetError(MS_CHILDERR, "Maximum number of items, %d, has been reached", "addParameter()", MS_DEFAULT_CGI_PARAMS);
}
self->ParamNames[self->NumParams] = strdup(name);
self->ParamValues[self->NumParams] = strdup(value);
self->ParamNames[self->NumParams] = msStrdup(name);
self->ParamValues[self->NumParams] = msStrdup(value);
self->NumParams++;
}

@@ -130,7 +130,7 @@
#endif /* USE_POINT_Z_M */

msPointToFormattedString(self, fmt, (char *) &buffer, 256);
return strdup(buffer);
return msStrdup(buffer);
}

%newobject toShape;
@@ -92,7 +92,7 @@
msRectToPolygon(*self, &shape);
shape.classindex = classindex;
if(text && layer->class[classindex]->numlabels > 0) {
shape.text = strdup(text);
shape.text = msStrdup(text);
}

ret = msDrawShape(map, layer, &shape, image, -1, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS);
@@ -156,7 +156,7 @@
char buffer[256];
char fmt[]="{ 'minx': %.16g , 'miny': %.16g , 'maxx': %.16g , 'maxy': %.16g }";
msRectToFormattedString(self, (char *) &fmt, (char *) &buffer, 256);
return strdup(buffer);
return msStrdup(buffer);
}

}
@@ -214,7 +214,7 @@
if (i >= 0 && i < self->numvalues)
{
msFree(self->values[i]);
self->values[i] = strdup(value);
self->values[i] = msStrdup(value);
if (!self->values[i])
{
return MS_FAILURE;
@@ -243,7 +243,7 @@
msSetError(MS_MEMERR, "Failed to allocate memory for values", "shapeObj()");
return;
} else {
for (i=0; i<numvalues; i++) self->values[i] = strdup("");
for (i=0; i<numvalues; i++) self->values[i] = msStrdup("");
}
self->numvalues = numvalues;
}
@@ -125,7 +125,7 @@
{
self->symbol = msGetSymbolIndex(&map->symbolset, symbolname, MS_TRUE);
if (self->symbolname) free((char*)self->symbolname);
if (symbolname) self->symbolname = strdup(symbolname);
if (symbolname) self->symbolname = msStrdup(symbolname);
else self->symbolname = 0;
return self->symbol;
}
@@ -156,7 +156,7 @@
self->numbindings--;
}

self->bindings[binding].item = strdup(item);
self->bindings[binding].item = msStrdup(item);
self->numbindings++;

return MS_SUCCESS;
@@ -44,7 +44,7 @@
symbolObj *symbol;
symbol = (symbolObj *) malloc(sizeof(symbolObj));
initSymbol(symbol);
symbol->name = strdup(symbolname);
symbol->name = msStrdup(symbolname);
if (imagefile) {
msLoadImageSymbol(symbol, imagefile);
}
@@ -39,7 +39,7 @@
symbolset = (symbolSetObj *) malloc(sizeof(symbolSetObj));
msInitSymbolSet(symbolset);
if (symbolfile) {
symbolset->filename = strdup(symbolfile);
symbolset->filename = msStrdup(symbolfile);
temp_map = msNewMapObj();
msLoadSymbolSet(symbolset, temp_map);
symbolset->map = NULL;

0 comments on commit dcb8291

Please sign in to comment.
You can’t perform that action at this time.