* dsm...@roadrunner.com <dsm...@roadrunner.com> [2014-04-10 12:36:48-0400]
> > +         {
> > +           free (nargv);
> >             return 0L;
> > +         }
> >         else
> >           nargv[nargi++] = narg;
> I don't understand this.  In both cases, free() will be called with an
> argument of 0, which does nothing.

My bad. It does not fix problem, that if realloc fails, it does not free
memory, but we blindly assign, losing pointer to previous memory chunk.

I will make another patch, like this

void* xrealloc(void *old_ptr, size_t new_size)
{
        void *new_ptr = realloc(old_ptr, new_size);
        if (!new_ptr)
                free(old_ptr);
        return new_ptr;
}

Suggestions, maybe more conventional name?

--
Best regards, Dmitry Bogatov <kact...@gnu.org>,
Free Software supporter, esperantisto and netiquette guardian.
        git://kaction.name/rc-files.git
        GPG: 54B7F00D

Reply via email to