mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-14 10:09:48 +00:00
hexdump(1): Simplify by using asprintf(3)
Instead of strlen() + calloc() + snprintf, just use asprintf(). No functional change. Obtained from: OpenBSD (CVS Rev. 1.22)
This commit is contained in:
parent
568415f29d
commit
0c9426b684
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=305990
@ -208,7 +208,6 @@ rewrite(FS *fs)
|
||||
unsigned char *p1, *p2, *fmtp;
|
||||
char savech, cs[3];
|
||||
int nconv, prec;
|
||||
size_t len;
|
||||
|
||||
prec = 0;
|
||||
|
||||
@ -389,10 +388,8 @@ isint2: switch(fu->bcnt) {
|
||||
*/
|
||||
savech = *p2;
|
||||
p1[0] = '\0';
|
||||
len = strlen(fmtp) + strlen(cs) + 1;
|
||||
if ((pr->fmt = calloc(1, len)) == NULL)
|
||||
if (asprintf(&pr->fmt, "%s%s", fmtp, cs) == -1)
|
||||
err(1, NULL);
|
||||
snprintf(pr->fmt, len, "%s%s", fmtp, cs);
|
||||
*p2 = savech;
|
||||
pr->cchar = pr->fmt + (p1 - fmtp);
|
||||
fmtp = p2;
|
||||
|
Loading…
Reference in New Issue
Block a user