Re: [xml] xml2 2.7.8 + gcc 4.5.2 unpredictable behaviour



I installed valgrind and run the test, you are right about the errors.
I change the calloc calls and it worked fine, that sounds strange to me , because the man page says that way of calling is supported.
 Thanks
   Emanuele

On Thu, Apr 14, 2011 at 10:17 AM, Emanuele Placidi <emanuele placidi gmail com> wrote:
Well, calloc accepts "nmemb" with 0 and it is used to alloc a single chunk of memory sized "size"
From man calloc:
void *calloc(size_t nmemb, size_t size);
....
 If nmemb or size is 0, then calloc() returns either NULL, or a unique pointer value that can later be successfully passed to free().
.....

Anyway thanks for your help, can you send me the valgrind output?.
Regards
   Zad

On Thu, Apr 14, 2011 at 3:11 AM, Noam Postavsky <npostavs users sourceforge net> wrote:
Emanuele Placidi <emanuele placidi gmail com> writes:

> Hi,
>  I would to point out a strange behaviour when storing in a structure an
> xmlChar pointer returned by xmlGetProp().
> In attach there is a very simple code which sig faults when compiled with gcc

Well I didn't get a segfault on my machine using gcc 4.5.2 and libxml2
2.7.8, but valgrind did indicate many errors. For instance line 369:

 reg=calloc(0,sizeof(struct register_desc));

You are allocating memory for 0 register_desc structs here. If this code
ever worked it was only by accident.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]