[GRASS5] MAXFILES in libgis too low

Glynn Clements glynn at gclements.plus.com
Sat Apr 2 20:07:37 EST 2005


Markus Neteler wrote:

> > > while trying to export a few hundred maps into a
> > > big ERDAS/IMG multichannel file (using the GDAL/GRASS plugin
> > > and gdal_merge.py), I stumbled over
> > > 
> > >  lib/gis/G.h :#define MAXFILES    256
> > > 
> > > While this number is lower than 365 days, Radim
> > > reminded me of the memory allocation.
> > > 
> > > How to deal with this problem? Simply changing
> > > MAXFILES to a higher number will cause problems
> > > on handhelds.
> > 
> > Low memory or stripped down kernel maxfiles?
> 
> No, it's sort of unrelated to kernel maxfiles.
> The point is that in lib/gis/G.h the fileinfo struct
> is allocated as fileinfo[MAXFILES]. So all the contents
> of this struct are allocated as often as MAXFILES is
> defined.

You could change it to "struct fileinfo *" and reallocate the array
dynamically. However, you would need to be careful about holding
pointers to the individual slots, as they may be relocated if the
array is resized.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list