[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
- Re: [Groff] problem with preconv and sample_docs.mom, (continued)
- Re: [Groff] problem with preconv and sample_docs.mom, Bjarni Ingi Gislason, 2017/11/05
- Re: [Groff] problem with preconv and sample_docs.mom, Peter Schaffter, 2017/11/05
- Re: [Groff] problem with preconv and sample_docs.mom, G. Branden Robinson, 2017/11/06
- Re: [Groff] problem with preconv and sample_docs.mom, Ingo Schwarze, 2017/11/06
- Re: [Groff] problem with preconv and sample_docs.mom, Tadziu Hoffmann, 2017/11/06
- Re: [Groff] problem with preconv and sample_docs.mom, James K. Lowden, 2017/11/07
- Re: [Groff] problem with preconv and sample_docs.mom,
Ralph Corderoy <=