=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/buf.c,v retrieving revision 1.18 retrieving revision 1.19 diff -c -r1.18 -r1.19 *** src/usr.bin/cvs/buf.c 2005/08/14 19:49:18 1.18 --- src/usr.bin/cvs/buf.c 2005/12/10 20:27:45 1.19 *************** *** 1,4 **** ! /* $OpenBSD: buf.c,v 1.18 2005/08/14 19:49:18 xsa Exp $ */ /* * Copyright (c) 2003 Jean-Francois Brousseau * All rights reserved. --- 1,4 ---- ! /* $OpenBSD: buf.c,v 1.19 2005/12/10 20:27:45 joris Exp $ */ /* * Copyright (c) 2003 Jean-Francois Brousseau * All rights reserved. *************** *** 38,45 **** #include "buf.h" #include "log.h" - #define BUF_INCR 128 --- 38,45 ---- #include "buf.h" #include "log.h" + #include "xmalloc.h" #define BUF_INCR 128 *************** *** 76,93 **** { BUF *b; ! b = (BUF *)malloc(sizeof(*b)); ! if (b == NULL) { ! cvs_log(LP_ERRNO, "failed to allocate buffer"); ! return (NULL); ! } ! ! b->cb_buf = malloc(len); ! if (b->cb_buf == NULL) { ! cvs_log(LP_ERRNO, "failed to allocate buffer"); ! free(b); ! return (NULL); ! } memset(b->cb_buf, 0, len); b->cb_flags = flags; --- 76,83 ---- { BUF *b; ! b = (BUF *)xmalloc(sizeof(*b)); ! b->cb_buf = xmalloc(len); memset(b->cb_buf, 0, len); b->cb_flags = flags; *************** *** 162,169 **** void cvs_buf_free(BUF *b) { ! free(b->cb_buf); ! free(b); } --- 152,159 ---- void cvs_buf_free(BUF *b) { ! xfree(b->cb_buf); ! xfree(b); } *************** *** 180,186 **** u_char *tmp; tmp = b->cb_buf; ! free(b); return (tmp); } --- 170,176 ---- u_char *tmp; tmp = b->cb_buf; ! xfree(b); return (tmp); } *************** *** 339,345 **** } ret = cvs_buf_append(b, str, (size_t)ret); ! free(str); return (ret); } --- 329,335 ---- } ret = cvs_buf_append(b, str, (size_t)ret); ! xfree(str); return (ret); } *************** *** 473,483 **** size_t diff; diff = b->cb_cur - b->cb_buf; ! tmp = realloc(b->cb_buf, b->cb_size + len); ! if (tmp == NULL) { ! cvs_log(LP_ERRNO, "failed to grow buffer"); ! return (-1); ! } b->cb_buf = (u_char *)tmp; b->cb_size += len; --- 463,469 ---- size_t diff; diff = b->cb_cur - b->cb_buf; ! tmp = xrealloc(b->cb_buf, b->cb_size + len); b->cb_buf = (u_char *)tmp; b->cb_size += len;