[mapserver-users] MS_MAXSYMBOLS

Steve Lime steve.lime at dnr.state.mn.us
Mon Sep 9 13:35:44 EDT 2002


No, it doesn't have to be that complex (i.e. lists) and what you suggest
is what
we use in several instances where hard limits are particularly useless.
However, with
things like classes/styles/layers it would be nice to be able do things
like changing
order (insterting in the middle) and actually deleting objects and
lists are much better
than arrays for those types of operations. Seems like if you're going
to cross that
bridge then might as well go all the way. I'm not keen on adding global
variables
again so we'd need object specifc counters to store allocated spaces.

Steve

Stephen Lime
Data & Applications Manager

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> Jan Hartmann <jhart at frw.uva.nl> 09/09/02 06:55AM >>>

> Not exactly of hotbed of advanced programming techniques, but then
again


> Layers and
> such are dynamically allocated but based upon a limit. Haven't had
time
> to go back and monkey with that. The limits become an issue  for
maybe
> one user a year, there is a workaround and there are always more
> pressing needs. If someone would like to help in converting arrays
to
> lists (layers/symbols/styles and so on) it would be welcomed.
> 


Steve, does it really have to be that complex? Couldn't you just 
reallocate a bigger bunch of memory when the maximum is reached? 
Something like


extern int MS_MAXSYMBOLS;   // in the header files
symbolObj *symbol;

int MS_MAXSYMBOLS = 64;     // in the c-file where you initialize
things
symbol = malloc(MS_MAXSYMBOLS * sizeof (symbolObj));

if (numsymbols == MS_MAXSYMBOLS) { // in mapsymbol.c
     MS_MAXSYMBOLS += 64;
     symbol = realloc(symbol,MS_MAXSYMBOLS*sizeof(symbolObj));
      .... nothing to be changed further on ...
}

Realloc allocates a new block of memory and copies the contents of the

old one to it.

Same would go for all MS_MAX... defines in map.h. Wouldn't this solve a

lot of problems without extensive rewriting? I hate doing lists in C.

Jan

Jan Hartmann
Department of Geography
University of Amsterdam
jhart at frw.uva.nl 







More information about the mapserver-users mailing list