|
From: Gong C. <g...@ac...> - 2003-09-07 03:51:34
|
I have a wired bug
the code is like this
printf("%d",i);
free(j);
printf("%d",i);
if we suppose i =1 ,the result should be
1
1
but in reality, the result is
1
0
The interesting thing is that if I use valgrind to run the program,
the result turn back to
1
1
anybody know what's the difference between normal free and the free in
valgrind?
Thanks a lot!
Gong
|
|
From: Benjamin L. <ben...@us...> - 2003-09-07 07:58:18
|
Your *normal* free() implementation sounds like it is non-ANSI C and non-POSIX compliant. Are you overriding it somewhere or using a malloc checking library? http://www.opengroup.org/onlinepubs/007904975/functions/free.html Can you supply details of your operating system, C library, compiler etc. and all that jazz? On Sunday, 2003-09-07 at 01:54:19 PM, Gong Cheng scribbled: > I have a wired bug > > the code is like this > > > printf("%d",i); > free(j); > printf("%d",i); > > if we suppose i =1 ,the result should be > 1 > 1 > but in reality, the result is > 1 > 0 > > The interesting thing is that if I use valgrind to run the program, > the result turn back to > 1 > 1 > > anybody know what's the difference between normal free and the free in > valgrind? > > Thanks a lot! > > Gong > -- Benjamin Lee Melbourne, Australia "Always real." http://www.realthought.net/ __________________________________________________________________________ Before destruction a man's heart is haughty, but humility goes before honour. -- Psalms 18:12 |
|
From: Benjamin L. <ben...@us...> - 2003-09-07 08:37:50
|
Oh... whoah... my bad, I read you email incorrectly. I didn't notice
the 'i' and 'j'. Please ignore my previous email.
Please see comments inserted below...
On Sunday, 2003-09-07 at 05:58:11 PM, Benjamin Lee scribbled:
*snip*
>
> On Sunday, 2003-09-07 at 01:54:19 PM, Gong Cheng scribbled:
> > I have a wired bug
> >
> > the code is like this
> >
> >
> > printf("%d",i);
> > free(j);
> > printf("%d",i);
> >
Can you explain what your 'i' variable has to do with 'j'?
> > if we suppose i =1 ,the result should be
> > 1
> > 1
> > but in reality, the result is
> > 1
> > 0
> >
> > The interesting thing is that if I use valgrind to run the program,
> > the result turn back to
> > 1
> > 1
> >
> > anybody know what's the difference between normal free and the free in
> > valgrind?
> >
> > Thanks a lot!
> >
> > Gong
> >
>
--
Benjamin Lee
Melbourne, Australia "Always real." http://www.realthought.net/
__________________________________________________________________________
What's another word for "thesaurus"?
-- Steven Wright
|