Markus Metz wrote:

> Any suggestions on how to compute required file size on 32bit OS with 
> sizeof(off_t) = 4 ?
> e.g.
> (double) nrows * ncols * sizeof(DCELL)
> or
> (long long int) nrows * ncols * sizeof(DCELL)
> more generic
> number_of_items * sizeof(item)
> 
> and safely compare that to 2^31 (2GB)?

Use double, cast to off_t, check that the two are equal, e.g.

        double d_size = (double) nrows * ncols * sizeof(DCELL);
        off_t size = (off_t) d_size;

        if ((double) size != d_size)
            G_fatal_error(_("File too large"));

-- 
Glynn Clements <[email protected]>
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to