Visite Webhosting Latino, el site sobre alojamiento web.
Impossible Leak realloc - Mombu the Programming Forum
Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > Impossible Leak realloc
User Name
REGISTER NOW! Mark Forums Read

sponsored links

1 19th June 22:04
External User
Posts: 1
Default Impossible Leak realloc

It's not legal C++ either, but with a fair number of adjustments...

There is no such header in C or in C++.

In C++, at least, main *must* return an int. In C it normally returns
an int as well, but I think the C standard allows a conformant compiler
to accept a void return as an extension. As an extension -- "void main"
is not standard conforming C.

This line shouldn't pass a C complier, although it is legal C++. If you

struct st_Test* pst_Test ;

it would be legal in both languages.

You don't need the test -- realloc is guaranteed to work correctly if
passed a NULL pointer.

I'm not sure what you are trying to do here, but you initialize the
pVoid element to a possibly invalid value, both in C and in C++.

If you want the equivalent of zero initialization, the standard idiom
would be to define a static object, and assign from it:

static struct st_Test zeroInitialized ;
pst_Test[ i ] = zeroInitialized ;

This line contains undefined behavior. Both in C and in C++.

Of course, since you never free any memory, it is normal that you have a
memory leak. The code returns from main, and the only pointer to your
structures disappears, so any checker will call it a leak.

James Kanze GABI Software
Conseils en informatique oriente objet/
Beratung in objektorientierter Datenverarbeitung
11 rue de Rambouillet, 78460 Chevreuse, France, Tl. : +33 (0)1 30 23 45 16

[ See for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
  Reply With Quote

  sponsored links


Thread Tools
Display Modes

Copyright 2006 - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -