groff
[Top][All Lists]
Advanced

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

Re: [Groff] problem with preconv and sample_docs.mom


From: Ralph Corderoy
Subject: Re: [Groff] problem with preconv and sample_docs.mom
Date: Wed, 08 Nov 2017 10:51:07 +0000

Hi jkl,

> >      ret = (char *)calloc(strlen(charset) + 1, 1);
> >      strcpy(ret, charset);
>
> As a logical matter, the calloc call should have the count as the first
> argument: 
>
>       ret = (char *)calloc(1, strlen(charset) + 1);

True, or just malloc(), as I think I pointed out, since all the zeroed
bytes are trampled by the strcpy().  And why not strdup(3), though not
knowing C++, having deliberately avoided it, perhaps that's not usual?

But this kind of thing is best accompanied by a scan of all the source
looking for patterns of things that can be cleaned up, and keeping those
ad-hoc searches to hand for regressions.

-- 
Cheers, Ralph.
https://plus.google.com/+RalphCorderoy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]