Opened 19 years ago
Closed 18 years ago
#1311 closed defect (wontfix)
reduce use of static variables in mapows.c
Reported by: | Owned by: | mapserverbugs | |
---|---|---|---|
Priority: | high | Milestone: | 4.6 release |
Component: | MapServer C Library | Version: | 4.5 |
Severity: | normal | Keywords: | |
Cc: |
Description
msOWSGetLayerExtent() and msOWSGetEPSGProj() use static strings to temporarily hold metadata. I'm changing these to char *value; msOWSGetEPSGProj() statically allocates memory for its return value static char epsgCode[20] =""; and to be thread safe, should return a pointer to a dynamically allocated string as is done in msOWSBuildURLFilename() (preceding function) for example.
Change History (3)
comment:2 by , 19 years ago
I don't understand why msOWSGetLayerExtent() uses a static variable. It should be enough to simply remove the static to solve this one. With respect to msOWSGetEPSGProj(), to save unnecessary buffer allocations (i.e. processing time) and to save us the code complexity of having to free() the returned value everywhere, I would like to suggest an alternative approach: make the function take a char * as argument to hold the result, like what we've done for msBuildPath() for instance. e.g. char projbuffer[MS_EPSG_BUFSIZE]; .... if (msOWSGetEPSGProj(projbuffer, &(map->projection),&(map->web.metadata), "MO", MS_FALSE) == NULL) { ... Internally, msOWSGetEPSGProj() would return either a ref to the "wms_epsg" metadata or copy the first EPSG code to projbuffer. The caller doesn't need to worry about whether his buffer is used or not, he just needs to pass a buffer of size MS_EPSG_BUFSIZE to the function. Makes sense?
Note:
See TracTickets
for help on using tickets.