diff options
author | jmallett <jmallett@FreeBSD.org> | 2002-05-17 05:11:07 +0000 |
---|---|---|
committer | jmallett <jmallett@FreeBSD.org> | 2002-05-17 05:11:07 +0000 |
commit | 0109c305458dc8e85d6497c140a58a9fce7df4f3 (patch) | |
tree | cf78d7652b64bccf0e61a4cef6f041a454a5bc4c /usr.bin/tsort | |
parent | 17aec9648900d65e6dc437b556bfd7a2789ad9b9 (diff) | |
download | FreeBSD-src-0109c305458dc8e85d6497c140a58a9fce7df4f3.zip FreeBSD-src-0109c305458dc8e85d6497c140a58a9fce7df4f3.tar.gz |
Clean up malloc(3)'s argument. Remove casts which do nothing when we're
using sizeof() anyway. Use slightly more consistent (per-file) error
reporting for malloc(3) returning NULL. If "malloc failed" was being printed,
don't use err(3). If a NULL format is being used, use err(3). In one case
errx(3) was being used with strerror(3), so just use err(3).
Diffstat (limited to 'usr.bin/tsort')
-rw-r--r-- | usr.bin/tsort/tsort.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/tsort/tsort.c b/usr.bin/tsort/tsort.c index 2a6a132..1c71b40 100644 --- a/usr.bin/tsort/tsort.c +++ b/usr.bin/tsort/tsort.c @@ -106,7 +106,7 @@ int debug, longest, quiet; void add_arc(char *, char *); int find_cycle(NODE *, NODE *, int, int); NODE *get_node(char *); -void *grow_buf(void *, int); +void *grow_buf(void *, size_t); void remove_node(NODE *); void clear_cycle(void); void tsort(void); @@ -192,9 +192,9 @@ main(argc, argv) void * grow_buf(bp, size) void *bp; - int size; + size_t size; { - if ((bp = realloc(bp, (u_int)size)) == NULL) + if ((bp = realloc(bp, size)) == NULL) err(1, NULL); return (bp); } @@ -335,8 +335,8 @@ tsort() */ for (cnt = 0, n = graph; n != NULL; n = n->n_next) ++cnt; - cycle_buf = malloc((u_int)sizeof(NODE *) * cnt); - longest_cycle = malloc((u_int)sizeof(NODE *) * cnt); + cycle_buf = malloc(sizeof(NODE *) * cnt); + longest_cycle = malloc(sizeof(NODE *) * cnt); if (cycle_buf == NULL || longest_cycle == NULL) err(1, NULL); } |