This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Can realloc be marked as a mallloc-like function?


On Mon, Jul 16, 2007 at 02:39:39PM -0000, Wolfram Gloger wrote:
> > int *p;
> > p = malloc (4);
> > *p = 0;
> > p = realloc (p, 4);
> > *p = 1;
> 
> By that reasoning, consider:
> 
>  int *p;
>  p = malloc (4);
>  *p = 0;
>  free(p);
>  p = malloc (4);
>  *p = 1;

Except that in the first sequence, the value of *p is retained across
the reallocation, so "*p = 0" is not dead.  The two examples aren't
really the same at all.


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]