# HG changeset patch # User Mike Becker # Date 1405336803 -7200 # Node ID 1e9012ad8215c97e4b941a474276d2c8647f7968 # Parent ee25d79a4187b45ee29e2ecb7bce36a00538bcd1 fixed stream copy bug + fixed doc issues in mempool diff -r ee25d79a4187 -r 1e9012ad8215 ucx/mempool.h --- a/ucx/mempool.h Mon Jul 14 12:45:48 2014 +0200 +++ b/ucx/mempool.h Mon Jul 14 13:20:03 2014 +0200 @@ -121,7 +121,7 @@ /** * Allocates a pooled memory array. * - * The contents of the allocated memory is set to zero. + * The content of the allocated memory is set to zero. * * @param pool the memory pool * @param nelem amount of elements to allocate @@ -142,7 +142,7 @@ * @param pool the memory pool * @param ptr a pointer to the memory that shall be reallocated * @param n the new size of the memory - * @return a pointer to the the location of the memory + * @return a pointer to the new location of the memory * @see ucx_allocator_realloc() */ void *ucx_mempool_realloc(UcxMempool *pool, void *ptr, size_t n); diff -r ee25d79a4187 -r 1e9012ad8215 ucx/utils.c --- a/ucx/utils.c Mon Jul 14 12:45:48 2014 +0200 +++ b/ucx/utils.c Mon Jul 14 13:20:03 2014 +0200 @@ -54,18 +54,22 @@ return 0; } + char *lbuf; size_t ncp = 0; - if (!buf) { - buf = (char*)malloc(bufsize); - if(buf == NULL) { + + if(buf) { + lbuf = buf; + } else { + lbuf = (char*)malloc(bufsize); + if(lbuf == NULL) { return 0; } } size_t r; size_t rn = bufsize > n ? n : bufsize; - while((r = readfnc(buf, 1, rn, src)) != 0) { - r = writefnc(buf, 1, r, dest); + while((r = readfnc(lbuf, 1, rn, src)) != 0) { + r = writefnc(lbuf, 1, r, dest); ncp += r; n -= r; rn = bufsize > n ? n : bufsize; @@ -74,7 +78,10 @@ } } - free(buf); + if (lbuf != buf) { + free(lbuf); + } + return ncp; }