diff options
-rw-r--r-- | args.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -76,23 +76,24 @@ struct args *args_copy(struct args *to, struct args *from) { to->fill = from->fill; to->list = from->list; - memcpy(to->arg, from->arg, sizeof *to->arg * to->fill); + memcpy(to->arg, from->arg, sizeof *from->arg * from->fill); return to; } struct args *args_copy_zap(struct args *to, struct args *from) { args_copy(to, from); - memset(from->arg, 0, sizeof *to->arg * to->fill); + memset(from->arg, 0, sizeof *from->arg * from->fill); return to; } struct args *args_cat_zap(struct args *to, struct args *from) { + size_t size = sizeof *from->arg * from->fill; to->list = from->list; - memcpy(to->arg + to->fill, from->arg, sizeof *from->arg * from->fill); + memcpy(to->arg + to->fill, from->arg, size); to->fill += from->fill; - memset(from->arg, 0, sizeof *to->arg * to->fill); + memset(from->arg, 0, size); return to; } |