[GRASS-dev] Re: [GRASS-SVN] r38597 - grass/trunk/vector/v.in.ogr

Hi,

2009/8/3 <svn_grass@osgeo.org>:

Modified:
grass/trunk/vector/v.in.ogr/main.c
Log:
there is no G_strdup in GRASS 7

should be G_strdup also included in GRASS7 or it's not necessary?

Martin

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

On Mon, Aug 3, 2009 at 5:06 PM, Martin Landa<landa.martin@gmail.com> wrote:

Hi,

2009/8/3 <svn_grass@osgeo.org>:

Modified:
grass/trunk/vector/v.in.ogr/main.c
Log:
there is no G_strdup in GRASS 7

should be G_strdup also included in GRASS7 or it's not necessary?

I guess that strdup() was changed to G_strdup() by Juergen in
GRASS 6 to avoid memory troubles on Windows.

@Juergen: is that guess correct?

thanks
Markus

Hi Markus,

On Mon, 03. Aug 2009 at 19:00:11 +0200, Markus Neteler wrote:

> 2009/8/3 <svn_grass@osgeo.org>:
>> Modified:
>> grass/trunk/vector/v.in.ogr/main.c
>> Log:
>> there is no G_strdup in GRASS 7
>
> should be G_strdup also included in GRASS7 or it's not necessary?

I guess that strdup() was changed to G_strdup() by Juergen in
GRASS 6 to avoid memory troubles on Windows.

@Juergen: is that guess correct?

Yes. Ogr_fieldname is freed later with G_free(), so it needs to be allocated
using a G_*() function like G_strdup().

Jürgen

--
Jürgen E. Fischer norBIT GmbH Tel. +49-4931-918175-20
Dipl.-Inf. (FH) Rheinstraße 13 Fax. +49-4931-918175-50
Software Engineer D-26506 Norden http://www.norbit.de

--
norBIT Gesellschaft fuer Unternehmensberatung und Informationssysteme mbH
Rheinstrasse 13, 26506 Norden
GF: Jelto Buurman, HR: Amtsgericht Emden, HRB 5502

On Mon, Aug 3, 2009 at 9:25 PM, Jürgen E.<jef@norbit.de> wrote:

On Mon, 03. Aug 2009 at 19:00:11 +0200, Markus Neteler wrote:

> 2009/8/3 <svn_grass@osgeo.org>:
>> Modified:
>> grass/trunk/vector/v.in.ogr/main.c
>> Log:
>> there is no G_strdup in GRASS 7
>
> should be G_strdup also included in GRASS7 or it's not necessary?

I guess that strdup() was changed to G_strdup() by Juergen in
GRASS 6 to avoid memory troubles on Windows.

@Juergen: is that guess correct?

Yes. Ogr_fieldname is freed later with G_free(), so it needs to be allocated
using a G_*() function like G_strdup().

Fixed in r38832 (GRASS 7).

Markus

Juergen:

Yes. Ogr_fieldname is freed later with G_free(), so it needs
to be allocated using a G_*() function like G_strdup().

note that G_free() isn't anything special, it just does:

/**
* \brief Free allocated memory.
*
* \param[in,out] buf buffer holding original data
*/

void G_free(void *buf)
{
    free(buf);
}

most of the G_malloc() stuff justs adds bounds checking and
prepares error messages; there are no #ifdefs in lib/gis/alloc.c
for Windows. I can't say that won't change in the future, but
for now...

Hamish

Hi Hamish,

On Sat, 22. Aug 2009 at 07:34:05 -0700, Hamish wrote:

Juergen:
> Yes. Ogr_fieldname is freed later with G_free(), so it needs
> to be allocated using a G_*() function like G_strdup().

note that G_free() isn't anything special, it just does:

It might look that way, but putting it into DLL makes it special. See also:
http://trac.osgeo.org/grass/ticket/468

Jürgen

--
Jürgen E. Fischer norBIT GmbH Tel. +49-4931-918175-20
Dipl.-Inf. (FH) Rheinstraße 13 Fax. +49-4931-918175-50
Software Engineer D-26506 Norden http://www.norbit.de

--
norBIT Gesellschaft fuer Unternehmensberatung und Informationssysteme mbH
Rheinstrasse 13, 26506 Norden
GF: Jelto Buurman, HR: Amtsgericht Emden, HRB 5502