RFC 17: Dynamic Array Sizing

Frank Warmerdam warmerdam at POBOX.COM
Fri May 12 16:02:54 EDT 2006


Ned Harding wrote:
> Is there any reason not to just use C++?  It would make stuff like this
> trivial to do.  MapServer already basically requires OGR which is C++,
> I'd be surprised if its compiled anywhere without a C++ compiler.

Ned,

Currently MapServer exposes many of the raw C structures to mapscript.
So turning them into nice C++ classes with proper data hiding and so
forth would be a dramatic shift and certainly not one I am willing to
contemplate.  In fact, this promiscuous exposure of structure internals
makes many kinds of dramatic changes difficult without breaking all
existing mapscript applications.

I would add that it is my intention for MapServer 5.0 to restructure
the mapogr.cpp to use the OGR C API since the C++ linkage to OGR
causes all sorts of fragility which is undesirable.

In this RFC I am aiming for a minimum of work and churn in order to
make the important objects all dynamically sized.

> And presuming that idea gets shot down, your RFC mentions growing stuff
> 1 object at a time.  I've already fixed 1 bug like that in MapServer,
> because when you have LOTS of objects that kills memory allocators and
> performance.  Growth should happen by a percentage so it doesn't have to
> happen too often.  I would recommend growing by at least 25% and double
> every time rarely seems like a mistake.

While I wasn't explicit in the RFC, the various "grow" functions will ensure
there is at least one additional object but will normally double the
allocation when growth is needed.  I am aware of the "grow by one" realloc
issue and will ensure it does not occur.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGF, http://osgeo.org



More information about the mapserver-dev mailing list