From ad6408e3849dae8bbb1fb25597ccd2f44af7cb36 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 5 Feb 2004 11:10:40 -0500 Subject: [svn-r8154] Purpose: Code cleanup Description: Minor tweaks, cleanups & optimizations to new bit operation routines. Platforms tested: FreeBSD 4.9 (sleipnir) too minor to require h5committest --- src/H5Tbit.c | 35 +++++++++++++++++++++-------------- src/H5Tconv.c | 7 +++---- src/H5Tpkg.h | 2 +- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/H5Tbit.c b/src/H5Tbit.c index d063137..ef62f31 100644 --- a/src/H5Tbit.c +++ b/src/H5Tbit.c @@ -27,6 +27,7 @@ #include "H5private.h" /*generic functions */ #include "H5Eprivate.h" /*error handling */ #include "H5Iprivate.h" /*ID functions */ +#include "H5MMprivate.h" /* Memory management */ #include "H5Tpkg.h" /*data-type functions */ /* Interface initialization */ @@ -177,36 +178,38 @@ H5T_bit_copy (uint8_t *dst, size_t dst_offset, const uint8_t *src, *------------------------------------------------------------------------- */ void -H5T_bit_shift (uint8_t *buf, hssize_t shift_dist, size_t buf_size) +H5T_bit_shift (uint8_t *buf, ssize_t shift_dist, size_t buf_size) { uint8_t *tmp_buf; size_t buf_size_bit = 8*buf_size; - size_t i; - FUNC_ENTER_NOAPI_NOINIT(H5T_bit_shift); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_bit_shift); + + /* Sanity check */ + assert(buf); + assert(buf_size); if(!shift_dist) goto done; - if(abs(shift_dist) >= buf_size_bit) { - H5T_bit_set (buf, 0, buf_size_bit, FALSE); + if(ABS(shift_dist) >= buf_size_bit) { + HDmemset(buf,0,buf_size); goto done; } - tmp_buf = (uint8_t*)HDcalloc(buf_size, 1); + tmp_buf = (uint8_t*)H5MM_calloc(buf_size); + assert(tmp_buf); /* Shift vector by making copies */ if(shift_dist > 0) /* left shift */ - H5T_bit_copy (tmp_buf, shift_dist, buf, 0, buf_size_bit-shift_dist); - else { /* right shift */ - shift_dist = -shift_dist; - H5T_bit_copy(tmp_buf, 0, buf, shift_dist, buf_size_bit-shift_dist); - } + H5T_bit_copy (tmp_buf, (size_t)shift_dist, buf, 0, (size_t)(buf_size_bit-shift_dist)); + else /* right shift */ + H5T_bit_copy(tmp_buf, 0, buf, (size_t)-shift_dist, (size_t)(buf_size_bit+shift_dist)); /* Copy back the vector */ - for(i=0; iu.atomic.precu.atomic.prec) { H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, src->u.atomic.prec); - /* Why is it set to TRUE? */ H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec, dst->u.atomic.prec-src->u.atomic.prec, TRUE); } else { H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, dst->u.atomic.prec); @@ -8468,8 +8467,8 @@ H5T_conv_f_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, /* Allocate enough space for the buffer holding temporary * converted value */ - buf_size = (int)pow(2, src.u.f.esize) / 8 + 1; - int_buf = (uint8_t*)HDcalloc(buf_size, 1); + buf_size = (int)HDpow((double)2.0, (double)src.u.f.esize) / 8 + 1; + int_buf = (uint8_t*)H5MM_calloc(buf_size); /* The conversion loop */ for (elmtno=0; elmtno