[GRASS-dev] Vect_read_line -> ERROR: G_calloc

Hello!

I'm trying to open a vector map with the Grass 6 API, but when I try to
read from the map, I get the following error message:

ERROR: G_calloc: unable to allocate 1861156242 * 4 bytes at
       allocation.c:144

The map I tr to read from is quite small, has only 3 features (one
polyline and two boundaries).

I try to use this code to read from the map:

extern "C" {
#include "grass/gis.h"
#include "grass/Vect.h"
}

#include <iostream>

int main(int argc, char **argv){

        using namespace std;

        struct Map_info Map;
        int ret;

        G_gisinit(argv[0]);

        ret=Vect_open_old(&Map, "polygonmap", "PERMANENT");

        cout<<"open level: "<<ret<<endl;
        cout<<"maptype: "<<Vect_maptype_info(&Map)<<endl;

        struct line_pnts line_p;
        struct line_cats line_c;
        Vect_read_line(&Map, &line_p, &line_c,1);

        return ret;
}

What am'I doing wrong?

Thanks for your help in advance,
István

"ifj. Stefán István" wrote:

Hello!

I'm trying to open a vector map with the Grass 6 API, but when I try to
read from the map, I get the following error message:

ERROR: G_calloc: unable to allocate 1861156242 * 4 bytes at
       allocation.c:144

        struct line_pnts line_p;
        struct line_cats line_c;
        Vect_read_line(&Map, &line_p, &line_c,1);

What am'I doing wrong?

You aren't initialising the structures.

The above lines should be e.g.:

    struct line_pnts *Points = Vect_new_line_struct();
    struct line_cats *Cats = Vect_new_cats_struct();
    Vect_read_line(&Map, line_p, line_c, 1);

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