Skip to content

Commit 05698a2

Browse files
committed
fix a few issues, and order of params
1 parent cbe9a30 commit 05698a2

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

usr.sbin/lpr/pac/pac.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ dumpit(void)
260260

261261
hp = hashtab[0];
262262
hno = 1;
263-
base = (struct hent **) calloc(sizeof hp, hcount);
263+
base = (struct hent **) calloc(hcount, sizeof(hp));
264264
for (ap = base, c = hcount; c--; ap++) {
265265
while (hp == NULL)
266266
hp = hashtab[hno++];
@@ -338,9 +338,8 @@ enter(const char name[])
338338
return(hp);
339339
h = hash(name);
340340
hcount++;
341-
hp = (struct hent *) calloc(sizeof *hp, (size_t)1);
342-
hp->h_name = (char *) calloc(sizeof(char), strlen(name)+1);
343-
strcpy(hp->h_name, name);
341+
hp = (struct hent *) calloc(1, sizeof(*hp));
342+
hp->h_name = strdup(name);
344343
hp->h_feetpages = 0.0;
345344
hp->h_count = 0;
346345
hp->h_link = hashtab[h];
@@ -441,10 +440,8 @@ chkprinter(const char *ptrname)
441440
errx(3, "accounting not enabled for printer %s", ptrname);
442441
if (!pflag && pp->price100)
443442
price = pp->price100/10000.0;
444-
sumfile = (char *) calloc(sizeof(char), strlen(acctfile)+5);
443+
asprintf(&sumfile, "%s_sum", acctfile);
445444
if (sumfile == NULL)
446-
errx(1, "calloc failed");
447-
strcpy(sumfile, acctfile);
448-
strcat(sumfile, "_sum");
445+
errx(1, "asprintf failed");
449446
return(1);
450447
}

0 commit comments

Comments
 (0)