@@ -260,7 +260,7 @@ dumpit(void)
260
260
261
261
hp = hashtab [0 ];
262
262
hno = 1 ;
263
- base = (struct hent * * ) calloc (sizeof hp , hcount );
263
+ base = (struct hent * * ) calloc (hcount , sizeof ( hp ) );
264
264
for (ap = base , c = hcount ; c -- ; ap ++ ) {
265
265
while (hp == NULL )
266
266
hp = hashtab [hno ++ ];
@@ -338,9 +338,8 @@ enter(const char name[])
338
338
return (hp );
339
339
h = hash (name );
340
340
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 );
344
343
hp -> h_feetpages = 0.0 ;
345
344
hp -> h_count = 0 ;
346
345
hp -> h_link = hashtab [h ];
@@ -441,10 +440,8 @@ chkprinter(const char *ptrname)
441
440
errx (3 , "accounting not enabled for printer %s" , ptrname );
442
441
if (!pflag && pp -> price100 )
443
442
price = pp -> price100 /10000.0 ;
444
- sumfile = ( char * ) calloc ( sizeof ( char ), strlen ( acctfile ) + 5 );
443
+ asprintf ( & sumfile , "%s_sum" , acctfile );
445
444
if (sumfile == NULL )
446
- errx (1 , "calloc failed" );
447
- strcpy (sumfile , acctfile );
448
- strcat (sumfile , "_sum" );
445
+ errx (1 , "asprintf failed" );
449
446
return (1 );
450
447
}
0 commit comments