diff --git a/src/h5_core/h5_syscall.c b/src/h5_core/h5_syscall.c index 9c9c010..3575be5 100644 --- a/src/h5_core/h5_syscall.c +++ b/src/h5_core/h5_syscall.c @@ -8,7 +8,8 @@ void * _h5_alloc ( h5_file_t * const f, void *ptr, - const size_t size ) { + const size_t size + ) { h5_debug ( f, "Allocating %ld bytes.", size ); ptr = realloc ( ptr, size ); if ( ptr == NULL ) { @@ -21,6 +22,24 @@ _h5_alloc ( return ptr; } +void * +_h5_calloc ( + h5_file_t * const f, + const size_t count, + const size_t size + ) { + h5_debug ( f, "Allocating %ld * %ld bytes.", count, size ); + void *ptr = calloc ( count, size ); + if ( ptr == NULL ) { + h5_error ( + f, + H5_ERR_NOMEM, + "Out of memory." ); + return (void*)(H5_ERR); + } + return ptr; +} + h5_err_t _h5_free ( h5_file_t * const f, diff --git a/src/h5_core/h5_syscall_private.h b/src/h5_core/h5_syscall_private.h index f0178e6..e01ab0f 100644 --- a/src/h5_core/h5_syscall_private.h +++ b/src/h5_core/h5_syscall_private.h @@ -8,6 +8,13 @@ _h5_alloc ( const size_t size ); +void * +_h5_calloc ( + h5_file_t * const f, + const size_t count, + const size_t size + ); + h5_err_t _h5_free ( h5_file_t * const f,