summaryrefslogtreecommitdiffabout
path: root/src/triplet.c
Unidiff
Diffstat (limited to 'src/triplet.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/triplet.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/triplet.c b/src/triplet.c
index 3083c64..9dfdf2c 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -57,12 +57,13 @@ hash_triplet_free (void *data)
57 txtacc_free (tp->acc); 57 txtacc_free (tp->acc);
58 58
59 /* Free uploader list */ 59 /* Free uploader list */
60 for (up = tp->uploader_list; up; ) 60 for (up = tp->uploader_list; up; )
61 { 61 {
62 struct uploader_info *next = up->next; 62 struct uploader_info *next = up->next;
63 free (up->fpr);
63 free (up); 64 free (up);
64 up = next; 65 up = next;
65 } 66 }
66 67
67 free (tp); 68 free (tp);
68} 69}
@@ -91,13 +92,13 @@ register_file (struct file_info *finfo, const struct spool *spool)
91 NULL, 92 NULL,
92 hash_triplet_free); 93 hash_triplet_free);
93 if (!triplet_table) 94 if (!triplet_table)
94 grecs_alloc_die (); 95 grecs_alloc_die ();
95 } 96 }
96 97
97 key.name = xmalloc (finfo->root_len + 1); 98 key.name = grecs_malloc (finfo->root_len + 1);
98 memcpy (key.name, finfo->name, finfo->root_len); 99 memcpy (key.name, finfo->name, finfo->root_len);
99 key.name[finfo->root_len] = 0; 100 key.name[finfo->root_len] = 0;
100 101
101 ret = grecs_symtab_lookup_or_install (triplet_table, &key, &install); 102 ret = grecs_symtab_lookup_or_install (triplet_table, &key, &install);
102 if (!ret) 103 if (!ret)
103 grecs_alloc_die (); 104 grecs_alloc_die ();
@@ -375,26 +376,26 @@ format_file_data (struct file_triplet *trp, enum file_type type, char **pret)
375 group_name = "unknown"; /* should not happen */ 376 group_name = "unknown"; /* should not happen */
376 else 377 else
377 group_name = grp->gr_name; 378 group_name = grp->gr_name;
378 379
379 /* Size */ 380 /* Size */
380 if (grecs_asprintf (&sptr, &slen, "%lu", (unsigned long) info->sb.st_size)) 381 if (grecs_asprintf (&sptr, &slen, "%lu", (unsigned long) info->sb.st_size))
381 xalloc_die (); 382 grecs_alloc_die ();
382 383
383 /* Figure out padding and format the buffer */ 384 /* Figure out padding and format the buffer */
384 slen = strlen (sptr); 385 slen = strlen (sptr);
385 pad = strlen (user_name) + 1 + strlen (group_name) + 1 + slen; 386 pad = strlen (user_name) + 1 + strlen (group_name) + 1 + slen;
386 if (pad > ugswidth) 387 if (pad > ugswidth)
387 ugswidth = pad; 388 ugswidth = pad;
388 389
389 if (grecs_asprintf (&buf, &size, 390 if (grecs_asprintf (&buf, &size,
390 "%s %s %s %*s %s %s", 391 "%s %s %s %*s %s %s",
391 modes, user_name, group_name, ugswidth - pad + slen, 392 modes, user_name, group_name, ugswidth - pad + slen,
392 sptr, 393 sptr,
393 timebuf, info->name)) 394 timebuf, info->name))
394 xalloc_die (); 395 grecs_alloc_die ();
395 free (sptr); 396 free (sptr);
396 *pret = buf; 397 *pret = buf;
397 return 0; 398 return 0;
398} 399}
399 400
400static const char * 401static const char *
@@ -408,13 +409,13 @@ expand_triplet_ls_full (struct metadef *def, void *data)
408 size += strlen (buf[file_dist]) + 1; 409 size += strlen (buf[file_dist]) + 1;
409 if (format_file_data (trp, file_signature, &buf[file_signature]) == 0) 410 if (format_file_data (trp, file_signature, &buf[file_signature]) == 0)
410 size += strlen (buf[file_signature]) + 1; 411 size += strlen (buf[file_signature]) + 1;
411 if (format_file_data (trp, file_directive, &buf[file_directive]) == 0) 412 if (format_file_data (trp, file_directive, &buf[file_directive]) == 0)
412 size += strlen (buf[file_directive]) + 1; 413 size += strlen (buf[file_directive]) + 1;
413 414
414 def->value = def->storage = xmalloc (size + 1); 415 def->value = def->storage = grecs_malloc (size + 1);
415 def->value[0] = 0; 416 def->value[0] = 0;
416 if (buf[file_dist]) 417 if (buf[file_dist])
417 { 418 {
418 strcat (def->value, buf[file_dist]); 419 strcat (def->value, buf[file_dist]);
419 strcat (def->value, "\n"); 420 strcat (def->value, "\n");
420 } 421 }
@@ -443,13 +444,13 @@ expand_triplet_ls_upload (struct metadef *def, void *data)
443 444
444 if (format_file_data (trp, file_dist, &buf[file_dist]) == 0) 445 if (format_file_data (trp, file_dist, &buf[file_dist]) == 0)
445 size += strlen (buf[file_dist]) + 1; 446 size += strlen (buf[file_dist]) + 1;
446 if (format_file_data (trp, file_signature, &buf[file_signature]) == 0) 447 if (format_file_data (trp, file_signature, &buf[file_signature]) == 0)
447 size += strlen (buf[file_signature]) + 1; 448 size += strlen (buf[file_signature]) + 1;
448 449
449 def->value = def->storage = xmalloc (size + 1); 450 def->value = def->storage = grecs_malloc (size + 1);
450 def->value[0] = 0; 451 def->value[0] = 0;
451 if (buf[file_dist]) 452 if (buf[file_dist])
452 { 453 {
453 strcat (def->value, buf[file_dist]); 454 strcat (def->value, buf[file_dist]);
454 strcat (def->value, "\n"); 455 strcat (def->value, "\n");
455 } 456 }
@@ -549,13 +550,13 @@ expand_email_user (struct metadef *def, void *data)
549 struct file_triplet *trp = data; 550 struct file_triplet *trp = data;
550 if (trp->uploader) 551 if (trp->uploader)
551 { 552 {
552 size_t size = 0; 553 size_t size = 0;
553 if (grecs_asprintf (&def->storage, &size, "\"%s\" <%s>", 554 if (grecs_asprintf (&def->storage, &size, "\"%s\" <%s>",
554 trp->uploader->realname, trp->uploader->email)) 555 trp->uploader->realname, trp->uploader->email))
555 xalloc_die (); 556 grecs_alloc_die ();
556 def->value = def->storage; 557 def->value = def->storage;
557 } 558 }
558 return def->value; 559 return def->value;
559} 560}
560 561
561static const char * 562static const char *
@@ -591,21 +592,21 @@ expand_check_result (struct metadef *def, void *data)
591 else if (WIFEXITED (status)) 592 else if (WIFEXITED (status))
592 { 593 {
593 size_t size = 0; 594 size_t size = 0;
594 def->storage = NULL; 595 def->storage = NULL;
595 if (grecs_asprintf (&def->storage, &size, 596 if (grecs_asprintf (&def->storage, &size,
596 "%d", WEXITSTATUS (status))) 597 "%d", WEXITSTATUS (status)))
597 xalloc_die (); 598 grecs_alloc_die ();
598 } 599 }
599 else if (WIFSIGNALED (status)) 600 else if (WIFSIGNALED (status))
600 { 601 {
601 size_t size = 0; 602 size_t size = 0;
602 def->storage = NULL; 603 def->storage = NULL;
603 if (grecs_asprintf (&def->storage, &size, "SIG+%d", 604 if (grecs_asprintf (&def->storage, &size, "SIG+%d",
604 WTERMSIG (status))) 605 WTERMSIG (status)))
605 xalloc_die (); 606 grecs_alloc_die ();
606 } 607 }
607 else 608 else
608 return def->value = "[unrecognized return code]"; 609 return def->value = "[unrecognized return code]";
609 return def->value = def->storage; 610 return def->value = def->storage;
610} 611}
611 612

Return to:

Send suggestions and report system problems to the System administrator.