From 8fbe8adddd5f52dd40ba7a9de323212249b37291 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Thu, 7 Apr 2022 05:39:30 -0700 Subject: Brings bin/restore.sh src/H5config.h.in cleanup from develop (#1608) --- bin/restore.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/restore.sh b/bin/restore.sh index 47dde11..0597572 100755 --- a/bin/restore.sh +++ b/bin/restore.sh @@ -48,6 +48,9 @@ rm -f bin/missing rm -f bin/test-driver rm -f bin/depcomp +echo "Remove files generated by autoheader" +rm -f src/H5config.h.in + echo "Remove files generated by bin/make_err" rm -f src/H5Epubgen.h rm -f src/H5Einit.h -- cgit v0.12 From e5f9f339404442550fa525cdc59597d503cca206 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Thu, 7 Apr 2022 05:59:35 -0700 Subject: Removes unused H5HP and H5MP packages (#1610) --- src/CMakeLists.txt | 27 -- src/H5HP.c | 904 ----------------------------------------- src/H5HPprivate.h | 68 ---- src/H5MP.c | 446 -------------------- src/H5MPmodule.h | 32 -- src/H5MPpkg.h | 99 ----- src/H5MPprivate.h | 57 --- src/H5MPtest.c | 213 ---------- src/Makefile.am | 3 +- test/CMakeLists.txt | 2 - test/CMakeTests.cmake | 8 +- test/Makefile.am | 4 +- test/pool.c | 794 ------------------------------------ test/testhdf5.c | 1 - test/testhdf5.h | 1 - test/theap.c | 1081 ------------------------------------------------- 16 files changed, 4 insertions(+), 3736 deletions(-) delete mode 100644 src/H5HP.c delete mode 100644 src/H5HPprivate.h delete mode 100644 src/H5MP.c delete mode 100644 src/H5MPmodule.h delete mode 100644 src/H5MPpkg.h delete mode 100644 src/H5MPprivate.h delete mode 100644 src/H5MPtest.c delete mode 100644 test/pool.c delete mode 100644 test/theap.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e08f485..df3eadf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -370,14 +370,6 @@ set (H5HL_HDRS IDE_GENERATED_PROPERTIES ("H5HL" "${H5HL_HDRS}" "${H5HL_SOURCES}" ) -set (H5HP_SOURCES - ${HDF5_SRC_DIR}/H5HP.c -) -set (H5HP_HDRS -) -IDE_GENERATED_PROPERTIES ("H5HP" "${H5HP_HDRS}" "${H5HP_SOURCES}" ) - - set (H5I_SOURCES ${HDF5_SRC_DIR}/H5I.c ${HDF5_SRC_DIR}/H5Idbg.c @@ -431,16 +423,6 @@ set (H5MM_HDRS IDE_GENERATED_PROPERTIES ("H5MM" "${H5MM_HDRS}" "${H5MM_SOURCES}" ) -set (H5MP_SOURCES - ${HDF5_SRC_DIR}/H5MP.c - ${HDF5_SRC_DIR}/H5MPtest.c -) - -set (H5MP_HDRS -) -IDE_GENERATED_PROPERTIES ("H5MP" "${H5MP_HDRS}" "${H5MP_SOURCES}" ) - - set (H5O_SOURCES ${HDF5_SRC_DIR}/H5O.c ${HDF5_SRC_DIR}/H5Oainfo.c @@ -733,7 +715,6 @@ set (H5_MODULE_HEADERS ${HDF5_SRC_DIR}/H5Lmodule.h ${HDF5_SRC_DIR}/H5Mmodule.h ${HDF5_SRC_DIR}/H5MFmodule.h - ${HDF5_SRC_DIR}/H5MPmodule.h ${HDF5_SRC_DIR}/H5Omodule.h ${HDF5_SRC_DIR}/H5Pmodule.h ${HDF5_SRC_DIR}/H5PBmodule.h @@ -769,13 +750,11 @@ set (common_SRCS ${H5HF_SOURCES} ${H5HG_SOURCES} ${H5HL_SOURCES} - ${H5HP_SOURCES} ${H5I_SOURCES} ${H5L_SOURCES} ${H5M_SOURCES} ${H5MF_SOURCES} ${H5MM_SOURCES} - ${H5MP_SOURCES} ${H5O_SOURCES} ${H5P_SOURCES} ${H5PB_SOURCES} @@ -818,7 +797,6 @@ set (H5_PUBLIC_HEADERS ${H5M_HDRS} ${H5MF_HDRS} ${H5MM_HDRS} - ${H5MP_HDRS} ${H5O_HDRS} ${H5P_HDRS} ${H5PB_HDRS} @@ -895,8 +873,6 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5HLpkg.h ${HDF5_SRC_DIR}/H5HLprivate.h - ${HDF5_SRC_DIR}/H5HPprivate.h - ${HDF5_SRC_DIR}/H5Ipkg.h ${HDF5_SRC_DIR}/H5Iprivate.h @@ -911,9 +887,6 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5MMprivate.h - ${HDF5_SRC_DIR}/H5MPpkg.h - ${HDF5_SRC_DIR}/H5MPprivate.h - ${HDF5_SRC_DIR}/H5Opkg.h ${HDF5_SRC_DIR}/H5Oprivate.h ${HDF5_SRC_DIR}/H5Oshared.h diff --git a/src/H5HP.c b/src/H5HP.c deleted file mode 100644 index d164223..0000000 --- a/src/H5HP.c +++ /dev/null @@ -1,904 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Purpose: Provides a heap abstract data type. - * - * (See chapter 11 - "Priority Queues" of _Algorithms_, by - * Sedgewick for additional information) - * - */ - -/* Private headers needed */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HPprivate.h" /* Heap routines */ -#include "H5FLprivate.h" /* Memory management functions */ - -/* Local Macros */ -#define H5HP_START_SIZE 16 /* Initial number of entries for heaps */ - -/* Private typedefs & structs */ - -/* Data structure for entries in the internal heap array */ -typedef struct { - int val; /* Value to be used for heap condition */ - H5HP_info_t *obj; /* Pointer to object stored in heap */ -} H5HP_ent_t; - -/* Main heap data structure */ -struct H5HP_t { - H5HP_type_t type; /* Type of heap (minimum or maximum value at "top") */ - size_t nobjs; /* Number of active objects in heap array */ - size_t nalloc; /* Number of allocated locations in heap array */ - H5HP_ent_t *heap; /* Pointer to array containing heap entries */ -}; - -/* Static functions */ -static herr_t H5HP__swim_max(H5HP_t *heap, size_t loc); -static herr_t H5HP__swim_min(H5HP_t *heap, size_t loc); -static herr_t H5HP__sink_max(H5HP_t *heap, size_t loc); -static herr_t H5HP__sink_min(H5HP_t *heap, size_t loc); - -/* Declare a free list to manage the H5HP_t struct */ -H5FL_DEFINE_STATIC(H5HP_t); - -/* Declare a free list to manage sequences of H5HP_ent_t */ -H5FL_SEQ_DEFINE_STATIC(H5HP_ent_t); - -/*-------------------------------------------------------------------------- - NAME - H5HP__swim_max - PURPOSE - Restore heap condition by moving an object upward - USAGE - herr_t H5HP__swim_max(heap, loc) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - size_t loc; IN: Location to start from - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Restore the heap condition for the heap's array by "swimming" the object - at a location upward. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This routine is for "maximum" value heaps. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5HP__swim_max(H5HP_t *heap, size_t loc) -{ - int val; /* Temporary copy value of object to move in heap */ - H5HP_info_t *obj; /* Temporary pointer to object to move in heap */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - /* Get copies of the information about the object to move in the heap */ - val = heap->heap[loc].val; - obj = heap->heap[loc].obj; - - /* Move object up in heap until it's reached the maximum location possible */ - while (heap->heap[loc / 2].val < val) { - /* Move object "above" current location in heap down */ - heap->heap[loc].val = heap->heap[loc / 2].val; - heap->heap[loc].obj = heap->heap[loc / 2].obj; - - /* Update heap location for object which moved */ - heap->heap[loc].obj->heap_loc = loc; - - /* Move to location "above" current location */ - loc = loc / 2; - } /* end while */ - - /* Put object into heap at correct location */ - heap->heap[loc].val = val; - heap->heap[loc].obj = obj; - - /* Update heap location for object */ - heap->heap[loc].obj->heap_loc = loc; - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP__swim_max() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP__swim_min - PURPOSE - Restore heap condition by moving an object upward - USAGE - herr_t H5HP__swim_min(heap, loc) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - size_t loc; IN: Location to start from - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Restore the heap condition for the heap's array by "swimming" the object - at a location upward. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This routine is for "minimum" value heaps. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5HP__swim_min(H5HP_t *heap, size_t loc) -{ - int val; /* Temporary copy value of object to move in heap */ - H5HP_info_t *obj; /* Temporary pointer to object to move in heap */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - /* Get copies of the information about the object to move in the heap */ - val = heap->heap[loc].val; - obj = heap->heap[loc].obj; - - /* Move object up in heap until it's reached the minimum location possible */ - while (heap->heap[loc / 2].val > val) { - /* Move object "above" current location in heap down */ - heap->heap[loc].val = heap->heap[loc / 2].val; - heap->heap[loc].obj = heap->heap[loc / 2].obj; - - /* Update heap location for object which moved */ - heap->heap[loc].obj->heap_loc = loc; - - /* Move to location "above" current location */ - loc = loc / 2; - } /* end while */ - - /* Put object into heap at correct location */ - heap->heap[loc].val = val; - heap->heap[loc].obj = obj; - - /* Update heap location for object */ - heap->heap[loc].obj->heap_loc = loc; - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP__swim_min() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP__sink_max - PURPOSE - Restore heap condition by moving an object downward - USAGE - herr_t H5HP__sink_max(heap, loc) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - size_t loc; IN: Location to start from - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Restore the heap condition for the heap's array by "sinking" the object - at a location downward. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This routine is for "maximum" value heaps. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5HP__sink_max(H5HP_t *heap, size_t loc) -{ - int val; /* Temporary copy value of object to move in heap */ - void * obj; /* Temporary pointer to object to move in heap */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - /* Get copies of the information about the object to move in the heap */ - val = heap->heap[loc].val; - obj = heap->heap[loc].obj; - - /* Move object up in heap until it's reached the maximum location possible */ - while ((2 * loc) <= heap->nobjs) { - size_t new_loc = loc * 2; /* New object's potential location area */ - - /* Get the greater of the two objects below the location in heap */ - if (new_loc < heap->nobjs && (heap->heap[new_loc].val < heap->heap[new_loc + 1].val)) - new_loc++; - - /* Check if the object is smaller than the larger of the objects below it */ - /* If so, its in the correct location now, and we can get out */ - if (val >= heap->heap[new_loc].val) - break; - - /* Move the greater of the two objects below the current location up */ - heap->heap[loc].val = heap->heap[new_loc].val; - heap->heap[loc].obj = heap->heap[new_loc].obj; - - /* Update heap location for object which moved */ - heap->heap[loc].obj->heap_loc = loc; - - /* Move to location "below" current location */ - loc = new_loc; - } /* end while */ - - /* Put object into heap at correct location */ - heap->heap[loc].val = val; - heap->heap[loc].obj = (H5HP_info_t *)obj; - - /* Update heap location for object */ - heap->heap[loc].obj->heap_loc = loc; - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP__sink_max() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP__sink_min - PURPOSE - Restore heap condition by moving an object downward - USAGE - herr_t H5HP__sink_min(heap, loc) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - size_t loc; IN: Location to start from - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Restore the heap condition for the heap's array by "sinking" the object - at a location downward. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This routine is for "minimum" value heaps. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5HP__sink_min(H5HP_t *heap, size_t loc) -{ - int val; /* Temporary copy value of object to move in heap */ - void * obj; /* Temporary pointer to object to move in heap */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - /* Get copies of the information about the object to move in the heap */ - val = heap->heap[loc].val; - obj = heap->heap[loc].obj; - - /* Move object up in heap until it's reached the maximum location possible */ - while ((2 * loc) <= heap->nobjs) { - size_t new_loc = loc * 2; /* New object's potential location area */ - - /* Get the lesser of the two objects below the location in heap */ - if (new_loc < heap->nobjs && (heap->heap[new_loc].val > heap->heap[new_loc + 1].val)) - new_loc++; - - /* Check if the object is greater than the larger of the objects below it */ - /* If so, its in the correct location now, and we can get out */ - if (val <= heap->heap[new_loc].val) - break; - - /* Move the greater of the two objects below the current location up */ - heap->heap[loc].val = heap->heap[new_loc].val; - heap->heap[loc].obj = heap->heap[new_loc].obj; - - /* Update heap location for object which moved */ - heap->heap[loc].obj->heap_loc = loc; - - /* Move to location "below" current location */ - loc = new_loc; - } /* end while */ - - /* Put object into heap at correct location */ - heap->heap[loc].val = val; - heap->heap[loc].obj = (H5HP_info_t *)obj; - - /* Update heap location for object */ - heap->heap[loc].obj->heap_loc = loc; - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP__sink_min() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_create - PURPOSE - Create a heap - USAGE - H5HP_t *H5HP_create(heap_type) - H5HP_type_t heap_type; IN: Type of heap to create - - RETURNS - Returns a pointer to a heap on success, NULL on failure. - DESCRIPTION - Create a priority queue. The SIZE is used to set the initial number of - entries allocated. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -H5HP_t * -H5HP_create(H5HP_type_t heap_type) -{ - H5HP_t *new_heap = NULL; /* Pointer to new heap object created */ - H5HP_t *ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Check args */ - HDassert(heap_type == H5HP_MIN_HEAP || heap_type == H5HP_MAX_HEAP); - - /* Allocate ref-counted string structure */ - if ((new_heap = H5FL_MALLOC(H5HP_t)) == NULL) - HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "memory allocation failed"); - - /* Allocate the array to store the heap entries */ - if ((new_heap->heap = H5FL_SEQ_MALLOC(H5HP_ent_t, (size_t)(H5HP_START_SIZE + 1))) == NULL) - HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "memory allocation failed"); - - /* Set the internal fields */ - new_heap->type = heap_type; - new_heap->nobjs = 0; - new_heap->nalloc = H5HP_START_SIZE + 1; - - /* Set the information in the 0'th location based on the type of heap */ - if (heap_type == H5HP_MIN_HEAP) { - /* Set the value in the '0' location to be the minimum value, to - * simplify the algorithms - */ - new_heap->heap[0].val = INT_MIN; - new_heap->heap[0].obj = NULL; - } /* end if */ - else { - /* Set the value in the '0' location to be the maximum value, to - * simplify the algorithms - */ - new_heap->heap[0].val = INT_MAX; - new_heap->heap[0].obj = NULL; - } /* end else */ - - /* Set the return value */ - ret_value = new_heap; - -done: - /* Error cleanup */ - if (NULL == ret_value) { - if (NULL != new_heap) { - if (NULL != new_heap->heap) - new_heap->heap = H5FL_SEQ_FREE(H5HP_ent_t, new_heap->heap); - new_heap = H5FL_FREE(H5HP_t, new_heap); - } /* end if */ - } /* end if */ - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_create() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_count - PURPOSE - Check the number of elements in a heap - USAGE - ssize_t H5HP_count(heap) - const H5HP_t *heap; IN: Pointer to heap to query - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Checks the number of elements in heap - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -ssize_t -H5HP_count(const H5HP_t *heap) -{ - ssize_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check args */ - HDassert(heap); - - /* Check internal consistency */ - /* (Pre-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - /* Return the number of objects in the heap */ - H5_CHECK_OVERFLOW(heap->nobjs, size_t, ssize_t); - ret_value = (ssize_t)heap->nobjs; - - /* No post-condition check necessary, since heap is constant */ - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_count() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_insert - PURPOSE - Insert an object into a heap, with an initial value - USAGE - herr_t H5HP_insert(heap, val, obj) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - int val; IN: Initial value for object in heap - void *obj; IN: Pointer to object to insert into heap - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Inserts a OBJ into a HEAP, with an initial VALue. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5HP_insert(H5HP_t *heap, int val, void *obj) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(heap); - HDassert(obj); - - /* Check internal consistency */ - /* (Pre-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - /* Increment number of objects in heap */ - heap->nobjs++; - - /* Check if we need to allocate more room for heap array */ - if (heap->nobjs >= heap->nalloc) { - size_t n = MAX(H5HP_START_SIZE, 2 * (heap->nalloc - 1)) + 1; - H5HP_ent_t *new_heap = H5FL_SEQ_REALLOC(H5HP_ent_t, heap->heap, n); - - if (!new_heap) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend heap array"); - heap->heap = new_heap; - heap->nalloc = n; - } /* end if */ - - /* Insert new object at end of heap */ - heap->heap[heap->nobjs].val = val; - heap->heap[heap->nobjs].obj = (H5HP_info_t *)obj; - heap->heap[heap->nobjs].obj->heap_loc = heap->nobjs; - - /* Restore heap condition */ - if (heap->type == H5HP_MAX_HEAP) { - if (H5HP__swim_max(heap, heap->nobjs) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "unable to restore heap condition"); - } /* end if */ - else { - if (H5HP__swim_min(heap, heap->nobjs) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "unable to restore heap condition"); - } /* end else */ - -done: - - /* Check internal consistency */ - /* (Post-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_insert() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_top - PURPOSE - Check the value of the top object in the heap - USAGE - herr_t H5HP_top(heap, val) - const H5HP_t *heap; IN: Pointer to heap to modify - int val; IN/OUT: Initial value for object in heap - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Checks the value of the top object in a heap - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5HP_top(const H5HP_t *heap, int *val) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check args */ - HDassert(heap); - HDassert(val); - - /* Check internal consistency */ - /* (Pre-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - /* Get value of the top object in the heap */ - *val = heap->heap[1].val; - - /* No post-condition check necessary, since heap is constant */ - FUNC_LEAVE_NOAPI(SUCCEED); -} /* end H5HP_top() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_remove - PURPOSE - Remove an object into a heap - USAGE - herr_t H5HP_remove(heap, val, obj) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - int *val; OUT: Pointer to value of object removed from heap - void **obj; OUT: Pointer to object removed from heap - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Removes the top object on a heap, returning its value and object pointer - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5HP_remove(H5HP_t *heap, int *val, void **obj) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(heap); - HDassert(val); - HDassert(obj); - - /* Check internal consistency */ - /* (Pre-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - /* Check if there are any objects on the heap to remove */ - if (heap->nobjs == 0) - HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "heap is empty"); - - /* Get the information for the top object on the heap */ - HDassert(heap->heap[1].obj->heap_loc == 1); - *val = heap->heap[1].val; - *obj = heap->heap[1].obj; - - /* Move the last element in the heap to the top */ - heap->heap[1].val = heap->heap[heap->nobjs].val; - heap->heap[1].obj = heap->heap[heap->nobjs].obj; - heap->heap[1].obj->heap_loc = 1; - - /* Decrement number of objects in heap */ - heap->nobjs--; - - /* Restore heap condition, if there are objects on the heap */ - if (heap->nobjs > 0) { - if (heap->type == H5HP_MAX_HEAP) { - if (H5HP__sink_max(heap, (size_t)1) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to restore heap condition"); - } /* end if */ - else { - if (H5HP__sink_min(heap, (size_t)1) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to restore heap condition"); - } /* end else */ - } /* end if */ - -done: - - /* Check internal consistency */ - /* (Post-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_remove() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_change - PURPOSE - Change the priority of an object on a heap - USAGE - herr_t H5HP_change(heap, val, obj) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - int val; IN: New priority value for object - void *obj; IN: Pointer to object to modify - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Changes the priority of an object on a heap. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5HP_change(H5HP_t *heap, int val, void *_obj) -{ - H5HP_info_t *obj = (H5HP_info_t *)_obj; /* Alias for object */ - size_t obj_loc; /* Location of object in heap */ - int old_val; /* Object's old priority value */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(heap); - HDassert(obj); - - /* Check internal consistency */ - /* (Pre-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - /* Get the location of the object in the heap */ - obj_loc = obj->heap_loc; - HDassert(obj_loc > 0 && obj_loc <= heap->nobjs); - - /* Change the heap object's priority */ - old_val = heap->heap[obj_loc].val; - heap->heap[obj_loc].val = val; - - /* Restore heap condition */ - if (val < old_val) { - if (heap->type == H5HP_MAX_HEAP) { - if (H5HP__sink_max(heap, obj_loc) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); - } /* end if */ - else { - if (H5HP__swim_min(heap, obj_loc) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); - } /* end else */ - } /* end if */ - else { - if (heap->type == H5HP_MAX_HEAP) { - if (H5HP__swim_max(heap, obj_loc) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); - } /* end if */ - else { - if (H5HP__sink_min(heap, obj_loc) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); - } /* end else */ - } /* end else */ - -done: - - /* Check internal consistency */ - /* (Post-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_change() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_incr - PURPOSE - Increment the priority of an object on a heap - USAGE - herr_t H5HP_incr(heap, amt, obj) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - unsigned amt; IN: Amount to increase priority by - void *obj; IN: Pointer to object to modify - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Increments the priority of an object on a heap by one. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5HP_incr(H5HP_t *heap, unsigned amt, void *_obj) -{ - H5HP_info_t *obj = (H5HP_info_t *)_obj; /* Alias for object */ - size_t obj_loc; /* Location of object in heap */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(heap); - HDassert(obj); - - /* Check internal consistency */ - /* (Pre-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - /* Get the location of the object in the heap */ - obj_loc = obj->heap_loc; - HDassert(obj_loc > 0 && obj_loc <= heap->nobjs); - - /* Change the heap object's priority */ - heap->heap[obj_loc].val += (int)amt; - - /* Restore heap condition */ - if (H5HP_MAX_HEAP == heap->type) { - if (H5HP__swim_max(heap, obj_loc) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition") - } /* end if */ - else { - if (H5HP__sink_min(heap, obj_loc) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition") - } /* end else */ - -done: - - /* Check internal consistency */ - /* (Post-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_incr() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_decr - PURPOSE - Decrement the priority of an object on a heap - USAGE - herr_t H5HP_dec(heap, amt, obj) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - unsigned amt; IN: Amount to decrease priority by - void *obj; IN: Pointer to object to modify - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Decrements the priority of an object on a heap by one. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5HP_decr(H5HP_t *heap, unsigned amt, void *_obj) -{ - H5HP_info_t *obj = (H5HP_info_t *)_obj; /* Alias for object */ - size_t obj_loc; /* Location of object in heap */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(heap); - HDassert(obj); - - /* Check internal consistency */ - /* (Pre-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - /* Get the location of the object in the heap */ - obj_loc = obj->heap_loc; - HDassert(obj_loc > 0 && obj_loc <= heap->nobjs); - - /* Change the heap object's priority */ - H5_CHECK_OVERFLOW(amt, unsigned, int); - heap->heap[obj_loc].val -= (int)amt; - - /* Restore heap condition */ - if (heap->type == H5HP_MAX_HEAP) { - if (H5HP__sink_max(heap, obj_loc) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); - } /* end if */ - else { - if (H5HP__swim_min(heap, obj_loc) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); - } /* end else */ - -done: - - /* Check internal consistency */ - /* (Post-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_decr() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_close - PURPOSE - Close a heap, deallocating it. - USAGE - herr_t H5HP_close(heap) - H5HP_t *heap; IN/OUT: Pointer to heap to close - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Close a heap, freeing all internal information. Any objects left in - the heap are not deallocated. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5HP_close(H5HP_t *heap) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check args */ - HDassert(heap); - - /* Check internal consistency */ - /* (Pre-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(NULL == heap->heap[0].obj); - - /* Free internal structures for heap */ - heap->heap = H5FL_SEQ_FREE(H5HP_ent_t, heap->heap); - - /* Free actual heap object */ - heap = H5FL_FREE(H5HP_t, heap); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HP_close() */ diff --git a/src/H5HPprivate.h b/src/H5HPprivate.h deleted file mode 100644 index 50020bc..0000000 --- a/src/H5HPprivate.h +++ /dev/null @@ -1,68 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * This file contains private information about the H5HP module - */ -#ifndef H5HPprivate_H -#define H5HPprivate_H - -/**************************************/ -/* Public headers needed by this file */ -/**************************************/ -#ifdef LATER -#include "H5HPpublic.h" -#endif /* LATER */ - -/***************************************/ -/* Private headers needed by this file */ -/***************************************/ -#include "H5private.h" - -/************/ -/* Typedefs */ -/************/ - -/* Typedef for heap struct (defined in H5HP.c) */ -typedef struct H5HP_t H5HP_t; - -/* Typedef for objects which can be inserted into heaps */ -/* This _must_ be the first field in objects which can be inserted into heaps */ -typedef struct H5HP_info_t { - size_t heap_loc; /* Location of object in heap */ -} H5HP_info_t; - -/* Typedef for type of heap to create */ -typedef enum { - H5HP_MIN_HEAP, /* Minimum values in heap are at the "top" */ - H5HP_MAX_HEAP /* Maximum values in heap are at the "top" */ -} H5HP_type_t; - -/**********/ -/* Macros */ -/**********/ - -/********************/ -/* Private routines */ -/********************/ -H5_DLL H5HP_t *H5HP_create(H5HP_type_t heap_type); -H5_DLL herr_t H5HP_insert(H5HP_t *heap, int val, void *obj); -H5_DLL ssize_t H5HP_count(const H5HP_t *heap); -H5_DLL herr_t H5HP_top(const H5HP_t *heap, int *val); -H5_DLL herr_t H5HP_remove(H5HP_t *heap, int *val, void **ptr); -H5_DLL herr_t H5HP_change(H5HP_t *heap, int val, void *obj); -H5_DLL herr_t H5HP_incr(H5HP_t *heap, unsigned amt, void *obj); -H5_DLL herr_t H5HP_decr(H5HP_t *heap, unsigned amt, void *obj); -H5_DLL herr_t H5HP_close(H5HP_t *heap); - -#endif /* H5HPprivate_H */ diff --git a/src/H5MP.c b/src/H5MP.c deleted file mode 100644 index 474a995..0000000 --- a/src/H5MP.c +++ /dev/null @@ -1,446 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/*------------------------------------------------------------------------- - * - * Created: H5MP.c - * May 2 2005 - * Quincey Koziol - * - * Purpose: Implements memory pools. (Similar to Apache's APR - * memory pools) - * - * Please see the documentation in: - * doc/html/TechNotes/MemoryPools.html for a full description - * of how they work, etc. - * - *------------------------------------------------------------------------- - */ - -#include "H5MPmodule.h" /* This source code file is part of the H5MP module */ - -/* Private headers */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5MPpkg.h" /* Memory Pools */ - -/****************/ -/* Local Macros */ -/****************/ - -/* Minimum sized block */ -#define H5MP_MIN_BLOCK (H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + H5MP_BLOCK_ALIGNMENT) - -/* First block in page */ -#define H5MP_PAGE_FIRST_BLOCK(p) \ - (H5MP_page_blk_t *)((void *)((unsigned char *)(p) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) - -/******************/ -/* Local Typedefs */ -/******************/ - -/********************/ -/* Local Prototypes */ -/********************/ - -/********************************/ -/* Package Variable Definitions */ -/********************************/ - -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - -/********************/ -/* Static Variables */ -/********************/ - -/* Declare a free list to manage the H5MP_pool_t struct */ -H5FL_DEFINE(H5MP_pool_t); - -/*------------------------------------------------------------------------- - * Function: H5MP_create - * - * Purpose: Create a new memory pool - * - * Return: Pointer to the memory pool "header" on success/NULL on failure - * - * Programmer: Quincey Koziol - * May 2 2005 - * - *------------------------------------------------------------------------- - */ -H5MP_pool_t * -H5MP_create(size_t page_size, unsigned flags) -{ - H5MP_pool_t *mp = NULL; /* New memory pool header */ - H5MP_pool_t *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Allocate space for the pool header */ - if (NULL == (mp = H5FL_MALLOC(H5MP_pool_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for memory pool header") - - /* Assign information */ - mp->page_size = H5MP_BLOCK_ALIGN(page_size); - mp->flags = flags; - - /* Initialize information */ - mp->free_size = 0; - mp->first = NULL; - mp->max_size = mp->page_size - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)); - - /* Create factory for pool pages */ - if (NULL == (mp->page_fac = H5FL_fac_init(page_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't create page factory") - - /* Set return value */ - ret_value = mp; - -done: - if (NULL == ret_value && mp) - if (H5MP_close(mp) < 0) - HDONE_ERROR(H5E_RESOURCE, H5E_CANTFREE, NULL, "unable to free memory pool header") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MP_create() */ - -/*------------------------------------------------------------------------- - * Function: H5MP__new_page - * - * Purpose: Allocate new page for a memory pool - * - * Return: Pointer to the page allocated on success/NULL on failure - * - * Programmer: Quincey Koziol - * May 4 2005 - * - *------------------------------------------------------------------------- - */ -static H5MP_page_t * -H5MP__new_page(H5MP_pool_t *mp, size_t page_size) -{ - H5MP_page_t * new_page; /* New page created */ - H5MP_page_blk_t *first_blk; /* Pointer to first block in page */ - H5MP_page_t * ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC - - /* Sanity check */ - HDassert(mp); - HDassert(page_size >= mp->page_size); - - /* Allocate page */ - if (page_size > mp->page_size) { - if (NULL == (new_page = (H5MP_page_t *)H5MM_malloc(page_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for page") - new_page->free_size = page_size - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)); - new_page->fac_alloc = FALSE; - } /* end if */ - else { - if (NULL == (new_page = (H5MP_page_t *)H5FL_FAC_MALLOC(mp->page_fac))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for page") - new_page->free_size = mp->max_size; - new_page->fac_alloc = TRUE; - } /* end else */ - - /* Initialize page information */ - first_blk = H5MP_PAGE_FIRST_BLOCK(new_page); - first_blk->size = new_page->free_size; - first_blk->page = new_page; - first_blk->is_free = TRUE; - first_blk->prev = NULL; - first_blk->next = NULL; - - /* Insert into page list */ - new_page->prev = NULL; - new_page->next = mp->first; - if (mp->first) - mp->first->prev = new_page; - mp->first = new_page; - - /* Account for new free space */ - new_page->free_blk = first_blk; - mp->free_size += new_page->free_size; - - /* Assign return value */ - ret_value = new_page; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MP__new_page() */ - -/*------------------------------------------------------------------------- - * Function: H5MP_malloc - * - * Purpose: Allocate space in a memory pool - * - * Return: Pointer to the space allocated on success/NULL on failure - * - * Programmer: Quincey Koziol - * May 2 2005 - * - *------------------------------------------------------------------------- - */ -void * -H5MP_malloc(H5MP_pool_t *mp, size_t request) -{ - H5MP_page_t * alloc_page = NULL; /* Page to allocate space from */ - H5MP_page_blk_t *alloc_free; /* Pointer to free space in page */ - size_t needed; /* Size requested, plus block header and alignment */ - void * ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Sanity check */ - HDassert(mp); - HDassert(request > 0); - - /* Compute actual size needed */ - needed = H5MP_BLOCK_ALIGN(request) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)); - - /* See if the request can be handled by existing free space */ - if (needed <= mp->free_size) { - size_t pool_free_avail; /* Amount of free space possibly available in pool */ - - /* Locate page with enough free space */ - alloc_page = mp->first; - pool_free_avail = mp->free_size; - while (alloc_page && pool_free_avail >= needed) { - /* If we found a page with enough free space, search for large - * enough free block on that page */ - if (alloc_page->free_size >= needed) { - size_t page_free_avail; /* Amount of free space possibly available */ - - /* Locate large enough block */ - alloc_free = alloc_page->free_blk; - page_free_avail = alloc_page->free_size; - while (alloc_free && page_free_avail >= needed) { - if (alloc_free->is_free) { - /* If we found a large enough block, leave now */ - if (alloc_free->size >= needed) - goto found; /* Needed to escape double "while" loop */ - - /* Decrement amount of potential space left */ - page_free_avail -= alloc_free->size; - } /* end if */ - - /* Go to next block */ - alloc_free = alloc_free->next; - } /* end while */ - } /* end if */ - - /* Decrement amount of potential space left */ - pool_free_avail -= alloc_page->free_size; - - /* Go to next page */ - alloc_page = alloc_page->next; - } /* end while */ - } /* end if */ - - { - size_t page_size; /* Size of page needed */ - - /* Check if the request is too large for a standard page */ - page_size = - (needed > mp->max_size) ? (needed + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) : mp->page_size; - - /* Allocate new page */ - if (NULL == (alloc_page = H5MP__new_page(mp, page_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for page") - - /* Set the block to allocate from */ - alloc_free = alloc_page->free_blk; - } /* end block */ - - /* Allocate space in page */ -found: - - /* Sanity check */ - HDassert(alloc_page); - HDassert(alloc_free); - - /* Check if we can subdivide the free space */ - if (alloc_free->size > (needed + H5MP_MIN_BLOCK)) { - H5MP_page_blk_t *new_free; /* New free block created */ - - /* Carve out new free block after block to allocate */ - new_free = (H5MP_page_blk_t *)((void *)(((unsigned char *)alloc_free) + needed)); - - /* Link into existing lists */ - new_free->next = alloc_free->next; - if (alloc_free->next) - alloc_free->next->prev = new_free; - new_free->prev = alloc_free; - alloc_free->next = new_free; - - /* Set blocks' information */ - new_free->size = alloc_free->size - needed; - new_free->is_free = TRUE; - new_free->page = alloc_free->page; - alloc_free->size = needed; - alloc_free->is_free = FALSE; - } /* end if */ - else { - /* Use whole free space block for new block */ - alloc_free->is_free = FALSE; - } /* end else */ - - /* Update page & pool's free size information */ - alloc_page->free_size -= alloc_free->size; - if (alloc_page->free_blk == alloc_free) - alloc_page->free_blk = alloc_free->next; - mp->free_size -= alloc_free->size; - - /* Set new space pointer for the return value */ - ret_value = ((unsigned char *)alloc_free) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MP_malloc() */ - -/*------------------------------------------------------------------------- - * Function: H5MP_free - * - * Purpose: Release space in a memory pool - * - * Return: NULL on success/NULL on failure - * - * Programmer: Quincey Koziol - * May 3 2005 - * - * Note: Should we release pages that have no used blocks? - * - *------------------------------------------------------------------------- - */ -void * -H5MP_free(H5MP_pool_t *mp, void *spc) -{ - H5MP_page_blk_t *spc_blk; /* Block for space to free */ - H5MP_page_t * spc_page; /* Page containing block to free */ - void * ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Sanity check */ - HDassert(mp); - HDassert(spc); - - /* Get block header for space to free */ - spc_blk = - (H5MP_page_blk_t *)((void *)(((unsigned char *)spc) - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)))); - - /* Mark block as free */ - HDassert(spc_blk->is_free == FALSE); - spc_blk->is_free = TRUE; - - /* Add it's space to the amount of free space in the page & pool */ - spc_page = spc_blk->page; - spc_page->free_size += spc_blk->size; - mp->free_size += spc_blk->size; - - /* Move page with newly freed space to front of list of pages in pool */ - if (spc_page != mp->first) { - /* Remove page from list */ - spc_page->prev->next = spc_page->next; - if (spc_page->next) - spc_page->next->prev = spc_page->prev; - - /* Insert page at beginning of list */ - spc_page->prev = NULL; - spc_page->next = mp->first; - mp->first->prev = spc_page; - mp->first = spc_page; - } /* end if */ - - /* Check if block can be merged with free space after it on page */ - if (spc_blk->next != NULL) { - H5MP_page_blk_t *next_blk; /* Block following space to free */ - - next_blk = spc_blk->next; - HDassert(next_blk->prev == spc_blk); - if (next_blk->is_free) { - spc_blk->size += next_blk->size; - spc_blk->next = next_blk->next; - } /* end if */ - } /* end if */ - - /* Check if block can be merged with free space before it on page */ - if (spc_blk->prev != NULL) { - H5MP_page_blk_t *prev_blk; /* Block before space to free */ - - prev_blk = spc_blk->prev; - HDassert(prev_blk->next == spc_blk); - if (prev_blk->is_free) { - prev_blk->size += spc_blk->size; - prev_blk->next = spc_blk->next; - } /* end if */ - } /* end if */ - - /* Check if the block freed becomes the first free block on the page */ - if (spc_page->free_blk == NULL || spc_blk < spc_page->free_blk) - spc_page->free_blk = spc_blk; - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MP_free() */ - -/*------------------------------------------------------------------------- - * Function: H5MP_close - * - * Purpose: Release all memory for a pool and destroy pool - * - * Return: Non-negative on success/negative on failure - * - * Programmer: Quincey Koziol - * May 3 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5MP_close(H5MP_pool_t *mp) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Release memory for pool pages */ - if (mp->first != NULL) { - H5MP_page_t *page, *next_page; /* Pointer to pages in pool */ - - /* Iterate through pages, releasing them */ - page = mp->first; - while (page) { - next_page = page->next; - - /* Free the page appropriately */ - if (page->fac_alloc) - page = (H5MP_page_t *)H5FL_FAC_FREE(mp->page_fac, page); - else - page = (H5MP_page_t *)H5MM_xfree(page); - - page = next_page; - } /* end while */ - } /* end if */ - - /* Release page factory */ - if (mp->page_fac) - if (H5FL_fac_term(mp->page_fac) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy page factory") - -done: - /* Free the memory pool itself */ - mp = H5FL_FREE(H5MP_pool_t, mp); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MP_close() */ diff --git a/src/H5MPmodule.h b/src/H5MPmodule.h deleted file mode 100644 index 8e34598..0000000 --- a/src/H5MPmodule.h +++ /dev/null @@ -1,32 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5MP package. Including this header means that the source file - * is part of the H5MP package. - */ -#ifndef H5MPmodule_H -#define H5MPmodule_H - -/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error - * reporting macros. - */ -#define H5MP_MODULE -#define H5_MY_PKG H5MP -#define H5_MY_PKG_ERR H5E_RESOURCE -#define H5_MY_PKG_INIT NO - -#endif /* H5MPmodule_H */ diff --git a/src/H5MPpkg.h b/src/H5MPpkg.h deleted file mode 100644 index 64c5293..0000000 --- a/src/H5MPpkg.h +++ /dev/null @@ -1,99 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Programmer: Quincey Koziol - * Monday, May 2, 2005 - * - * Purpose: This file contains declarations which are visible only within - * the H5MP package. Source files outside the H5MP package should - * include H5MPprivate.h instead. - */ -#if !(defined H5MP_FRIEND || defined H5MP_MODULE) -#error "Do not include this file outside the H5MP package!" -#endif - -#ifndef H5MPpkg_H -#define H5MPpkg_H - -/* Get package's private header */ -#include "H5MPprivate.h" /* Memory Pools */ - -/* Other private headers needed by this file */ -#include "H5FLprivate.h" /* Free Lists */ - -/**************************/ -/* Package Private Macros */ -/**************************/ - -/* Alignment macros */ -/* (Ideas from Apache APR :-) */ - -/* Default alignment necessary */ -#define H5MP_BLOCK_ALIGNMENT 8 - -/* General alignment macro */ -/* (this only works for aligning to power of 2 boundary) */ -#define H5MP_ALIGN(x, a) (((x) + ((size_t)(a)) - 1) & ~(((size_t)(a)) - 1)) - -/* Default alignment */ -#define H5MP_BLOCK_ALIGN(x) H5MP_ALIGN(x, H5MP_BLOCK_ALIGNMENT) - -/****************************/ -/* Package Private Typedefs */ -/****************************/ - -/* Free block in pool */ -typedef struct H5MP_page_blk_t { - size_t size; /* Size of block (includes this H5MP_page_blk_t info) */ - unsigned is_free : 1; /* Flag to indicate the block is free */ - struct H5MP_page_t * page; /* Pointer to page block is located in */ - struct H5MP_page_blk_t *prev; /* Pointer to previous block in page */ - struct H5MP_page_blk_t *next; /* Pointer to next block in page */ -} H5MP_page_blk_t; - -/* Memory pool page */ -typedef struct H5MP_page_t { - size_t free_size; /* Total amount of free space in page */ - unsigned fac_alloc : 1; /* Flag to indicate the page was allocated by the pool's factory */ - H5MP_page_blk_t * free_blk; /* Pointer to first free block in page */ - struct H5MP_page_t *next; /* Pointer to next page in pool */ - struct H5MP_page_t *prev; /* Pointer to previous page in pool */ -} H5MP_page_t; - -/* Memory pool header */ -struct H5MP_pool_t { - H5FL_fac_head_t *page_fac; /* Free-list factory for pages */ - size_t page_size; /* Page size for pool */ - size_t free_size; /* Total amount of free space in pool */ - size_t max_size; /* Maximum block that will fit in a standard page */ - H5MP_page_t * first; /* Pointer to first page in pool */ - unsigned flags; /* Bit flags for pool settings */ -}; - -/*****************************************/ -/* Package Private Variable Declarations */ -/*****************************************/ - -/******************************/ -/* Package Private Prototypes */ -/******************************/ -#ifdef H5MP_TESTING -H5_DLL herr_t H5MP_get_pool_free_size(const H5MP_pool_t *mp, size_t *free_size); -H5_DLL htri_t H5MP_pool_is_free_size_correct(const H5MP_pool_t *mp); -H5_DLL herr_t H5MP_get_pool_first_page(const H5MP_pool_t *mp, H5MP_page_t **page); -H5_DLL herr_t H5MP_get_page_free_size(const H5MP_page_t *mp, size_t *page); -H5_DLL herr_t H5MP_get_page_next_page(const H5MP_page_t *page, H5MP_page_t **next_page); -#endif /* H5MP_TESTING */ - -#endif /* H5MPpkg_H */ diff --git a/src/H5MPprivate.h b/src/H5MPprivate.h deleted file mode 100644 index 2b06650..0000000 --- a/src/H5MPprivate.h +++ /dev/null @@ -1,57 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/*------------------------------------------------------------------------- - * - * Created: H5MPprivate.h - * May 2 2005 - * Quincey Koziol - * - * Purpose: Private header for memory pool routines. - * - *------------------------------------------------------------------------- - */ - -#ifndef H5MPprivate_H -#define H5MPprivate_H - -/* Include package's public header (not yet) */ -/* #include "H5MPpublic.h" */ - -/* Private headers needed by this file */ - -/**************************/ -/* Library Private Macros */ -/**************************/ - -/* Pool creation flags */ -/* Default settings */ -#define H5MP_FLG_DEFAULT 0 -#define H5MP_PAGE_SIZE_DEFAULT 4096 /* (bytes) */ - -/****************************/ -/* Library Private Typedefs */ -/****************************/ - -/* Memory pool header (defined in H5MPpkg.c) */ -typedef struct H5MP_pool_t H5MP_pool_t; - -/***************************************/ -/* Library-private Function Prototypes */ -/***************************************/ -H5_DLL H5MP_pool_t *H5MP_create(size_t page_size, unsigned flags); -H5_DLL void * H5MP_malloc(H5MP_pool_t *mp, size_t request); -H5_DLL void * H5MP_free(H5MP_pool_t *mp, void *spc); -H5_DLL herr_t H5MP_close(H5MP_pool_t *mp); - -#endif /* H5MPprivate_H */ diff --git a/src/H5MPtest.c b/src/H5MPtest.c deleted file mode 100644 index 27e7bbe..0000000 --- a/src/H5MPtest.c +++ /dev/null @@ -1,213 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* Programmer: Quincey Koziol - * Tuesday, May 3, 2005 - * - * Purpose: Memory pool testing functions. - */ - -#include "H5MPmodule.h" /* This source code file is part of the H5MP module */ -#define H5MP_TESTING /*include H5MP testing funcs*/ - -/* Private headers */ -#include "H5private.h" /* Generic Functions */ -#include "H5MPpkg.h" /* Memory Pools */ -#include "H5Eprivate.h" /* Error handling */ - -/* Static Prototypes */ - -/* Package variables */ - -/*------------------------------------------------------------------------- - * Function: H5MP_get_pool_free_size - * - * Purpose: Retrieve the total amount of free space in entire pool - * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Quincey Koziol - * Tuesday, May 3, 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5MP_get_pool_free_size(const H5MP_pool_t *mp, size_t *free_size) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check arguments. */ - HDassert(mp); - HDassert(free_size); - - /* Get memory pool's free space */ - *free_size = mp->free_size; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MP_get_pool_free_size() */ - -/*------------------------------------------------------------------------- - * Function: H5MP_get_pool_first_page - * - * Purpose: Retrieve the first page in a memory pool - * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Quincey Koziol - * Tuesday, May 3, 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5MP_get_pool_first_page(const H5MP_pool_t *mp, H5MP_page_t **page) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check arguments. */ - HDassert(mp); - HDassert(page); - - /* Get memory pool's first page */ - *page = mp->first; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MP_get_pool_first_page() */ - -/*------------------------------------------------------------------------- - * Function: H5MP_pool_is_free_size_correct - * - * Purpose: Check that the free space reported in each page corresponds - * to the free size in each page and that the free space in the - * free blocks for a page corresponds with the free space for - * the page. - * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Quincey Koziol - * Wednesday, May 3, 2005 - * - *------------------------------------------------------------------------- - */ -htri_t -H5MP_pool_is_free_size_correct(const H5MP_pool_t *mp) -{ - H5MP_page_t *page; /* Pointer to current page */ - size_t pool_free; /* Size of pages' free space */ - htri_t ret_value = TRUE; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check arguments. */ - HDassert(mp); - - /* Iterate through pages, checking the free size & accumulating the - * free space for all the pages */ - page = mp->first; - pool_free = 0; - while (page != NULL) { - H5MP_page_blk_t *blk; /* Pointer to current free block */ - size_t page_free; /* Size of blocks on free list */ - - /* Iterate through the blocks in page, accumulating free space */ - blk = (H5MP_page_blk_t *)((void *)((unsigned char *)page + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))); - page_free = 0; - while (blk != NULL) { - if (blk->is_free) - page_free += blk->size; - blk = blk->next; - } /* end while */ - - /* Check that the free space from the blocks on the free list - * corresponds to space in page */ - if (page_free != page->free_size) - HGOTO_DONE(FALSE) - - /* Increment the amount of free space in pool */ - pool_free += page->free_size; - - /* Advance to next page */ - page = page->next; - } /* end while */ - - /* Check that the free space from the pages - * corresponds to free space in pool */ - if (pool_free != mp->free_size) - HGOTO_DONE(FALSE) - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5MP_pool_is_free_size_correct() */ - -/*------------------------------------------------------------------------- - * Function: H5MP_get_page_free_size - * - * Purpose: Retrieve the amount of free space in given page - * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Quincey Koziol - * Tuesday, May 3, 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5MP_get_page_free_size(const H5MP_page_t *page, size_t *free_size) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check arguments. */ - HDassert(page); - HDassert(free_size); - - /* Get memory page's free space */ - *free_size = page->free_size; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MP_get_page_free_size() */ - -/*------------------------------------------------------------------------- - * Function: H5MP_get_page_next_page - * - * Purpose: Retrieve the next page in the pool - * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Quincey Koziol - * Tuesday, May 3, 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5MP_get_page_next_page(const H5MP_page_t *page, H5MP_page_t **next_page) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check arguments. */ - HDassert(page); - HDassert(next_page); - - /* Get next memory page */ - *next_page = page->next; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MP_get_page_next_page() */ diff --git a/src/Makefile.am b/src/Makefile.am index ab9e13a..b2c0e05 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -73,12 +73,11 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5lib_settings.c H5system.c \ H5HFspace.c H5HFstat.c H5HFtest.c H5HFtiny.c \ H5HG.c H5HGcache.c H5HGdbg.c H5HGquery.c \ H5HL.c H5HLcache.c H5HLdbg.c H5HLint.c H5HLprfx.c H5HLdblk.c \ - H5HP.c \ H5I.c H5Idbg.c H5Iint.c H5Itest.c \ H5L.c H5Ldeprec.c H5Lexternal.c \ H5M.c \ H5MF.c H5MFaggr.c H5MFdbg.c H5MFsection.c \ - H5MM.c H5MP.c H5MPtest.c \ + H5MM.c \ H5O.c H5Odeprec.c H5Oainfo.c H5Oalloc.c H5Oattr.c H5Oattribute.c \ H5Obogus.c H5Obtreek.c H5Ocache.c H5Ocache_image.c H5Ochunk.c \ H5Ocont.c H5Ocopy.c H5Ocopy_ref.c H5Odbg.c H5Odrvinfo.c H5Odtype.c \ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8fea613..77aeba0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -222,7 +222,6 @@ set (testhdf5_SOURCES ${HDF5_TEST_SOURCE_DIR}/tgenprop.c ${HDF5_TEST_SOURCE_DIR}/th5o.c ${HDF5_TEST_SOURCE_DIR}/th5s.c - ${HDF5_TEST_SOURCE_DIR}/theap.c ${HDF5_TEST_SOURCE_DIR}/tid.c ${HDF5_TEST_SOURCE_DIR}/titerate.c ${HDF5_TEST_SOURCE_DIR}/tmeta.c @@ -275,7 +274,6 @@ set (H5_TESTS earray btree2 fheap - pool accum hyperslab istore diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index 77672d5..bdaca75 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -205,18 +205,12 @@ add_test ( ) set_tests_properties (H5TEST-testhdf5-clear-objects PROPERTIES FIXTURES_SETUP clear_testhdf5) -add_test (NAME H5TEST-testhdf5-base COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -x heap -x file -x select) +add_test (NAME H5TEST-testhdf5-base COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -x file -x select) set_tests_properties (H5TEST-testhdf5-base PROPERTIES FIXTURES_REQUIRED clear_testhdf5 ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) -add_test (NAME H5TEST-testhdf5-heap COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -o heap) -set_tests_properties (H5TEST-testhdf5-heap PROPERTIES - FIXTURES_REQUIRED clear_testhdf5 - ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" - WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST -) add_test (NAME H5TEST-testhdf5-file COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -o file) set_tests_properties (H5TEST-testhdf5-file PROPERTIES FIXTURES_REQUIRED clear_testhdf5 diff --git a/test/Makefile.am b/test/Makefile.am index 27ea4f3..0273c3d 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -62,7 +62,7 @@ check_SCRIPTS = $(TEST_SCRIPT) TEST_PROG= testhdf5 \ cache cache_api cache_image cache_tagging lheap ohdr \ stab gheap evict_on_close farray earray btree2 fheap \ - pool accum hyperslab istore bittests dt_arith page_buffer \ + accum hyperslab istore bittests dt_arith page_buffer \ dtypes dsets chunk_info cmpd_dset cmpd_dtransform filter_fail extend direct_chunk \ external efc objcopy objcopy_ref links unlink twriteorder big mtime \ fillval mount \ @@ -231,7 +231,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse # Sources for testhdf5 executable testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \ - tgenprop.c th5o.c th5s.c tcoords.c theap.c tid.c titerate.c tmeta.c tmisc.c \ + tgenprop.c th5o.c th5s.c tcoords.c tid.c titerate.c tmeta.c tmisc.c \ trefer.c trefer_deprec.c trefstr.c tselect.c tskiplist.c tsohm.c ttime.c tunicode.c \ tvlstr.c tvltypes.c diff --git a/test/pool.c b/test/pool.c deleted file mode 100644 index c508025..0000000 --- a/test/pool.c +++ /dev/null @@ -1,794 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* Programmer: Quincey Koziol - * Tuesday, May 3, 2005 - */ -#include "h5test.h" - -/* - * This file needs to access private datatypes from the H5MP package. - * This file also needs to access the memory pool testing code. - */ -#define H5MP_FRIEND /*suppress error about including H5MPpkg */ -#define H5MP_TESTING -#include "H5MPpkg.h" /* Memory Pools */ - -/* Other private headers that this test requires */ - -/* Local macros */ -#define MPOOL_PAGE_SIZE H5MP_PAGE_SIZE_DEFAULT -#define MPOOL_FLAGS H5MP_FLG_DEFAULT -#define MPOOL_NUM_NORMAL_BLOCKS 15 -#define MPOOL_NORMAL_BLOCK 512 -#define MPOOL_LARGE_BLOCK (MPOOL_PAGE_SIZE * 3) -#define MPOOL_NUM_SMALL_BLOCKS 64 -#define MPOOL_SMALL_BLOCK 1 -#define MPOOL_NUM_RANDOM (10 * 1024) -#define MPOOL_RANDOM_MAX_SIZE (MPOOL_PAGE_SIZE * 2) - -/*------------------------------------------------------------------------- - * Function: test_create - * - * Purpose: Test trivial creating & closing memory pool - * - * Return: Success: 0 - * Failure: 1 - * - * Programmer: Quincey Koziol - * Tuesday, May 3, 2005 - * - *------------------------------------------------------------------------- - */ -static int -test_create(void) -{ - H5MP_pool_t *mp; /* Memory pool */ - H5MP_page_t *page; /* Memory pool page */ - size_t free_size; /* Free size in pool */ - - /* - * Test memory pool creation - */ - TESTING("memory pool creation"); - - /* Create a memory pool */ - if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) - TEST_ERROR - - /* Check free space */ - if (H5MP_get_pool_free_size(mp, &free_size) < 0) - TEST_ERROR - if (free_size != 0) - TEST_ERROR - - /* Check first page */ - if (H5MP_get_pool_first_page(mp, &page) < 0) - TEST_ERROR - if (page != NULL) - TEST_ERROR - - /* Close the memory pool */ - if (H5MP_close(mp) < 0) - TEST_ERROR - - PASSED(); - - return 0; - -error: - H5E_BEGIN_TRY - { - if (mp) - H5MP_close(mp); - } - H5E_END_TRY; - - return 1; -} /* test_create() */ - -/*------------------------------------------------------------------------- - * Function: test_close_one - * - * Purpose: Tests closing pool with one block allocated - * - * Return: Success: 0 - * Failure: 1 - * - * Programmer: Quincey Koziol - * Friday, May 6, 2005 - * - *------------------------------------------------------------------------- - */ -static int -test_close_one(void) -{ - H5MP_pool_t *mp; /* Memory pool */ - - /* - * Test memory pool closing - */ - TESTING("closing pool with blocks still allocated in one page"); - - /* Create a memory pool */ - if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) - TEST_ERROR - - /* Allocate space in pool */ - if (NULL == H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK)) - TEST_ERROR - - /* Close the memory pool */ - if (H5MP_close(mp) < 0) - TEST_ERROR - - PASSED(); - - return 0; - -error: - H5E_BEGIN_TRY - { - if (mp) - H5MP_close(mp); - } - H5E_END_TRY; - - return 1; -} /* test_close_one() */ - -/*------------------------------------------------------------------------- - * Function: test_allocate_first - * - * Purpose: Tests allocating first block in pool - * - * Return: Success: 0 - * Failure: 1 - * - * Programmer: Quincey Koziol - * Tuesday, May 3, 2005 - * - *------------------------------------------------------------------------- - */ -static int -test_allocate_first(void) -{ - H5MP_pool_t *mp; /* Memory pool */ - H5MP_page_t *page; /* Memory pool page */ - size_t free_size; /* Free size in pool */ - void * spc; /* Pointer to space allocated */ - - /* - * Test memory pool allocation - */ - TESTING("allocating first block in pool"); - - /* Create a memory pool */ - if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) - TEST_ERROR - - /* Allocate space in pool */ - if (NULL == (spc = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))) - TEST_ERROR - - /* Check pool's free space */ - if (H5MP_get_pool_free_size(mp, &free_size) < 0) - TEST_ERROR - if (free_size != - MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) - TEST_ERROR - - /* Get first page */ - if (H5MP_get_pool_first_page(mp, &page) < 0) - TEST_ERROR - if (page == NULL) - TEST_ERROR - - /* Check page's free space */ - if (H5MP_get_page_free_size(page, &free_size) < 0) - TEST_ERROR - if (free_size != - MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) - TEST_ERROR - - /* Check that free space totals match */ - if (H5MP_pool_is_free_size_correct(mp) <= 0) - TEST_ERROR - - /* Check next page */ - if (H5MP_get_page_next_page(page, &page) < 0) - TEST_ERROR - if (page != NULL) - TEST_ERROR - - /* Free space in pool */ - H5MP_free(mp, spc); - - /* Check pool's free space */ - if (H5MP_get_pool_free_size(mp, &free_size) < 0) - TEST_ERROR - if (free_size != MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) - TEST_ERROR - - /* Check that free space totals match */ - if (H5MP_pool_is_free_size_correct(mp) <= 0) - TEST_ERROR - - /* Close the memory pool */ - if (H5MP_close(mp) < 0) - TEST_ERROR - - PASSED(); - - TESTING("allocating large first block in pool"); - - /* Create a memory pool */ - if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) - TEST_ERROR - - /* Allocate space in pool */ - if (NULL == (spc = H5MP_malloc(mp, (size_t)MPOOL_LARGE_BLOCK))) - TEST_ERROR - - /* Check pool's free space */ - if (H5MP_get_pool_free_size(mp, &free_size) < 0) - TEST_ERROR - if (free_size != 0) - TEST_ERROR - - /* Get first page */ - if (H5MP_get_pool_first_page(mp, &page) < 0) - TEST_ERROR - if (page == NULL) - TEST_ERROR - - /* Check page's free space */ - if (H5MP_get_page_free_size(page, &free_size) < 0) - TEST_ERROR - if (free_size != 0) - TEST_ERROR - - /* Check that free space totals match */ - if (H5MP_pool_is_free_size_correct(mp) <= 0) - TEST_ERROR - - /* Check next page */ - if (H5MP_get_page_next_page(page, &page) < 0) - TEST_ERROR - if (page != NULL) - TEST_ERROR - - /* Free space in pool */ - H5MP_free(mp, spc); - - /* Check pool's free space */ - if (H5MP_get_pool_free_size(mp, &free_size) < 0) - TEST_ERROR - if (free_size != MPOOL_LARGE_BLOCK + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) - TEST_ERROR - - /* Check that free space totals match */ - if (H5MP_pool_is_free_size_correct(mp) <= 0) - TEST_ERROR - - /* Close the memory pool */ - if (H5MP_close(mp) < 0) - TEST_ERROR - - PASSED(); - - return 0; - -error: - H5E_BEGIN_TRY - { - if (mp) - H5MP_close(mp); - } - H5E_END_TRY; - - return 1; -} /* test_allocate_first() */ - -/*------------------------------------------------------------------------- - * Function: test_allocate_split - * - * Purpose: Tests allocating block in pool that requires splitting - * existing block - * - * Return: Success: 0 - * Failure: 1 - * - * Programmer: Quincey Koziol - * Tuesday, May 3, 2005 - * - *------------------------------------------------------------------------- - */ -static int -test_allocate_split(void) -{ - H5MP_pool_t *mp; /* Memory pool */ - size_t free_size; /* Free size in pool */ - void * spc1; /* Pointer to space allocated */ - void * spc2; /* Pointer to space allocated */ - - /* - * Test memory pool allocation - */ - TESTING("splitting block in pool"); - - /* Create a memory pool */ - if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) - TEST_ERROR - - /* Allocate space in pool */ - if (NULL == (spc1 = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))) - TEST_ERROR - - /* Check pool's free space */ - if (H5MP_get_pool_free_size(mp, &free_size) < 0) - TEST_ERROR - if (free_size != - MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) - TEST_ERROR - - /* Check that free space totals match */ - if (H5MP_pool_is_free_size_correct(mp) <= 0) - TEST_ERROR - - /* Allocate more space in pool */ - if (NULL == (spc2 = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))) - TEST_ERROR - - /* Check pool's free space */ - if (H5MP_get_pool_free_size(mp, &free_size) < 0) - TEST_ERROR - if (free_size != - MPOOL_PAGE_SIZE - - (((H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) * 2) + - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) - TEST_ERROR - - /* Check that free space totals match */ - if (H5MP_pool_is_free_size_correct(mp) <= 0) - TEST_ERROR - - /* Free first block in pool */ - H5MP_free(mp, spc1); - - /* Check pool's free space */ - if (H5MP_get_pool_free_size(mp, &free_size) < 0) - TEST_ERROR - if (free_size != - MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) - TEST_ERROR - - /* Check that free space totals match */ - if (H5MP_pool_is_free_size_correct(mp) <= 0) - TEST_ERROR - - /* Free second block in pool (should merge with first block) */ - H5MP_free(mp, spc2); - - /* Check pool's free space */ - if (H5MP_get_pool_free_size(mp, &free_size) < 0) - TEST_ERROR - if (free_size != MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) - TEST_ERROR - - /* Check that free space totals match */ - if (H5MP_pool_is_free_size_correct(mp) <= 0) - TEST_ERROR - - /* Close the memory pool */ - if (H5MP_close(mp) < 0) - TEST_ERROR - - PASSED(); - - return 0; - -error: - H5E_BEGIN_TRY - { - if (mp) - H5MP_close(mp); - } - H5E_END_TRY; - - return 1; -} /* test_allocate_split() */ - -/*------------------------------------------------------------------------- - * Function: test_allocate_many_small - * - * Purpose: Tests allocating many small blocks in a pool - * - * Return: Success: 0 - * Failure: 1 - * - * Programmer: Quincey Koziol - * Tuesday, May 6, 2005 - * - *------------------------------------------------------------------------- - */ -static int -test_allocate_many_small(void) -{ - H5MP_pool_t *mp; /* Memory pool */ - size_t free_size; /* Free size in pool */ - void * spc[MPOOL_NUM_SMALL_BLOCKS]; /* Pointers to space allocated */ - int i; /* Local index variable */ - - /* - * Test memory pool allocation - */ - TESTING("allocating many small blocks"); - - /* Create a memory pool */ - if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) - TEST_ERROR - - /* Allocate space in pool */ - for (i = 0; i < MPOOL_NUM_SMALL_BLOCKS; i++) - if (NULL == (spc[i] = H5MP_malloc(mp, (size_t)MPOOL_SMALL_BLOCK))) - TEST_ERROR - - /* Check pool's free space */ - if (H5MP_get_pool_free_size(mp, &free_size) < 0) - TEST_ERROR - if (free_size != MPOOL_PAGE_SIZE - - (((H5MP_BLOCK_ALIGN(MPOOL_SMALL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) * - MPOOL_NUM_SMALL_BLOCKS) + - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) - TEST_ERROR - - /* Check that free space totals match */ - if (H5MP_pool_is_free_size_correct(mp) <= 0) - TEST_ERROR - - /* Free blocks in pool */ - /* (Tests free block merging with block after it */ - for (i = (MPOOL_NUM_SMALL_BLOCKS - 1); i >= 0; i--) - H5MP_free(mp, spc[i]); - - /* Check pool's free space */ - if (H5MP_get_pool_free_size(mp, &free_size) < 0) - TEST_ERROR - if (free_size != MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) - TEST_ERROR - - /* Check that free space totals match */ - if (H5MP_pool_is_free_size_correct(mp) <= 0) - TEST_ERROR - - /* Close the memory pool */ - if (H5MP_close(mp) < 0) - TEST_ERROR - - PASSED(); - - return 0; - -error: - H5E_BEGIN_TRY - { - if (mp) - H5MP_close(mp); - } - H5E_END_TRY; - - return 1; -} /* test_allocate_many_small() */ - -/*------------------------------------------------------------------------- - * Function: test_allocate_new_page - * - * Purpose: Tests allocating block in pool that requires allocating - * new page - * - * Return: Success: 0 - * Failure: 1 - * - * Programmer: Quincey Koziol - * Friday, May 6, 2005 - * - *------------------------------------------------------------------------- - */ -static int -test_allocate_new_page(void) -{ - H5MP_pool_t *mp; /* Memory pool */ - size_t free_size; /* Free size in pool */ - size_t u; /* Local index variable */ - void * spc[MPOOL_NUM_NORMAL_BLOCKS]; /* Pointer to space allocated */ - void * spc1; /* Pointer to space allocated */ - void * spc2; /* Pointer to space allocated */ - - /* - * Test memory pool allocation - */ - TESTING("allocate normal-sized block in new page"); - - /* Create a memory pool */ - if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) - TEST_ERROR - - /* Allocate space in pool */ - for (u = 0; u < MPOOL_NUM_NORMAL_BLOCKS; u++) - if (NULL == (spc[u] = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))) - TEST_ERROR - - /* Check pool's free space */ - if (H5MP_get_pool_free_size(mp, &free_size) < 0) - TEST_ERROR - if (free_size != (MPOOL_PAGE_SIZE * 3) - (((H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) * - MPOOL_NUM_NORMAL_BLOCKS) + - (H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)) * 3))) - TEST_ERROR - - /* Check that free space totals match */ - if (H5MP_pool_is_free_size_correct(mp) <= 0) - TEST_ERROR - - /* Free blocks in pool */ - /* (Free alternating blocks, in two passes, which tests block merging w/both neighbors) */ - for (u = 0; u < MPOOL_NUM_NORMAL_BLOCKS; u += 2) - H5MP_free(mp, spc[u]); - for (u = 1; u < MPOOL_NUM_NORMAL_BLOCKS; u += 2) - H5MP_free(mp, spc[u]); - - /* Check pool's free space */ - if (H5MP_get_pool_free_size(mp, &free_size) < 0) - TEST_ERROR - if (free_size != ((MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) * 3)) - TEST_ERROR - - /* Check that free space totals match */ - if (H5MP_pool_is_free_size_correct(mp) <= 0) - TEST_ERROR - - /* Close the memory pool */ - if (H5MP_close(mp) < 0) - TEST_ERROR - - PASSED(); - - TESTING("allocate large-sized block in new page"); - - /* Create a memory pool */ - if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) - TEST_ERROR - - /* Allocate space in pool */ - /* (Normal sized block) */ - if (NULL == (spc1 = H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))) - TEST_ERROR - /* (Larger sized block) */ - if (NULL == (spc2 = H5MP_malloc(mp, (size_t)MPOOL_LARGE_BLOCK))) - TEST_ERROR - - /* Check pool's free space */ - if (H5MP_get_pool_free_size(mp, &free_size) < 0) - TEST_ERROR - if (free_size != - MPOOL_PAGE_SIZE - (H5MP_BLOCK_ALIGN(MPOOL_NORMAL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) - TEST_ERROR - - /* Check that free space totals match */ - if (H5MP_pool_is_free_size_correct(mp) <= 0) - TEST_ERROR - - /* Free blocks in pool */ - H5MP_free(mp, spc1); - H5MP_free(mp, spc2); - - /* Check pool's free space */ - if (H5MP_get_pool_free_size(mp, &free_size) < 0) - TEST_ERROR - if (free_size != ((MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) + MPOOL_LARGE_BLOCK + - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)))) - TEST_ERROR - - /* Check that free space totals match */ - if (H5MP_pool_is_free_size_correct(mp) <= 0) - TEST_ERROR - - /* Close the memory pool */ - if (H5MP_close(mp) < 0) - TEST_ERROR - - PASSED(); - - return 0; - -error: - H5E_BEGIN_TRY - { - if (mp) - H5MP_close(mp); - } - H5E_END_TRY; - - return 1; -} /* test_allocate_new_page() */ - -/*------------------------------------------------------------------------- - * Function: test_allocate_random - * - * Purpose: Tests allocating random sized blocks in pool - * - * Return: Success: 0 - * Failure: 1 - * - * Programmer: Quincey Koziol - * Friday, May 6, 2005 - * - *------------------------------------------------------------------------- - */ -static int -test_allocate_random(void) -{ - H5MP_pool_t *mp; /* Memory pool */ - size_t u; /* Local index variable */ - time_t curr_time; /* Current time, for seeding random number generator */ - size_t * blk_size = NULL; /* Pointer to block sizes */ - void ** spc = NULL; /* Pointer to space allocated */ - size_t swap_idx; /* Location to swap with when shuffling */ - void * swap_ptr; /* Pointer to swap when shuffling */ - - /* - * Test memory pool allocation - */ - TESTING("allocate many random sized blocks"); - - /* Initialize random number seed */ - curr_time = HDtime(NULL); -#if 0 -curr_time=1115412944; -HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); -#endif - HDsrandom((unsigned)curr_time); - - /* Create a memory pool */ - if (NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS))) - TEST_ERROR - - /* Allocate space for the block sizes */ - if (NULL == (blk_size = (size_t *)HDmalloc(sizeof(size_t) * MPOOL_NUM_RANDOM))) - TEST_ERROR - - /* Allocate space for the block pointers */ - if (NULL == (spc = (void **)HDmalloc(sizeof(void *) * MPOOL_NUM_RANDOM))) - TEST_ERROR - - /* Initialize the block sizes with random values */ - for (u = 0; u < MPOOL_NUM_RANDOM; u++) - blk_size[u] = (size_t)(HDrandom() % MPOOL_RANDOM_MAX_SIZE) + 1; - - /* Allocate space in pool */ - for (u = 0; u < MPOOL_NUM_RANDOM; u++) - if (NULL == (spc[u] = H5MP_malloc(mp, blk_size[u]))) - TEST_ERROR - - /* Check that free space totals match */ - if (H5MP_pool_is_free_size_correct(mp) <= 0) - TEST_ERROR - - /* Shuffle pointers to free */ - for (u = 0; u < MPOOL_NUM_RANDOM; u++) { - swap_idx = (size_t)(HDrandom() % (int)(MPOOL_NUM_RANDOM - u)) + u; - swap_ptr = spc[u]; - spc[u] = spc[swap_idx]; - spc[swap_idx] = swap_ptr; - } /* end for */ - - /* Free blocks in pool */ - for (u = 0; u < MPOOL_NUM_RANDOM; u++) - H5MP_free(mp, spc[u]); - - /* Check that free space totals match */ - if (H5MP_pool_is_free_size_correct(mp) <= 0) - TEST_ERROR - - /* Initialize the block sizes with random values */ - for (u = 0; u < MPOOL_NUM_RANDOM; u++) - blk_size[u] = (size_t)(HDrandom() % MPOOL_RANDOM_MAX_SIZE) + 1; - - /* Allocate space in pool (again) */ - /* (Leave allocated to test closing pool with many blocks still allocated) */ - for (u = 0; u < MPOOL_NUM_RANDOM; u++) - if (NULL == (spc[u] = H5MP_malloc(mp, blk_size[u]))) - TEST_ERROR - - /* Check that free space totals match */ - if (H5MP_pool_is_free_size_correct(mp) <= 0) - TEST_ERROR - - /* Close the memory pool */ - if (H5MP_close(mp) < 0) - TEST_ERROR - - /* Free memory for block sizes & pointers */ - HDfree(blk_size); - HDfree(spc); - - PASSED(); - - return 0; - -error: - if (blk_size) - HDfree(blk_size); - if (spc) - HDfree(spc); - H5E_BEGIN_TRY - { - if (mp) - H5MP_close(mp); - } - H5E_END_TRY; - - return 1; -} /* test_allocate_random() */ - -/*------------------------------------------------------------------------- - * Function: main - * - * Purpose: Test the memory pool code - * - * Return: Success: - * Failure: - * - * Programmer: Quincey Koziol - * Tuesday, May 3, 2005 - * - *------------------------------------------------------------------------- - */ -int -main(void) -{ - int nerrors = 0; - - /* Reset library */ - h5_reset(); - - /* Test memory pool creation */ - nerrors += test_create(); - - /* Test memory pool space closing */ - nerrors += test_close_one(); - - /* Test memory pool space allocation */ - nerrors += test_allocate_first(); - nerrors += test_allocate_split(); - nerrors += test_allocate_many_small(); - nerrors += test_allocate_new_page(); - nerrors += test_allocate_random(); - - if (nerrors) - goto error; - HDputs("All memory pool tests passed."); - - return 0; - -error: - HDputs("*** TESTS FAILED ***"); - return 1; -} diff --git a/test/testhdf5.c b/test/testhdf5.c index 45c0f9f..a1d7594 100644 --- a/test/testhdf5.c +++ b/test/testhdf5.c @@ -45,7 +45,6 @@ main(int argc, char *argv[]) AddTest("config", test_configure, cleanup_configure, "Configure definitions", NULL); AddTest("metadata", test_metadata, cleanup_metadata, "Encoding/decoding metadata", NULL); AddTest("checksum", test_checksum, cleanup_checksum, "Checksum algorithm", NULL); - AddTest("heap", test_heap, NULL, "Memory Heaps", NULL); AddTest("skiplist", test_skiplist, NULL, "Skip Lists", NULL); AddTest("refstr", test_refstr, NULL, "Reference Counted Strings", NULL); AddTest("file", test_file, cleanup_file, "Low-Level File I/O", NULL); diff --git a/test/testhdf5.h b/test/testhdf5.h index ba5fa71..c5b8246 100644 --- a/test/testhdf5.h +++ b/test/testhdf5.h @@ -203,7 +203,6 @@ extern "C" { /* Prototypes for the test routines */ void test_metadata(void); void test_checksum(void); -void test_heap(void); void test_refstr(void); void test_file(void); void test_h5o(void); diff --git a/test/theap.c b/test/theap.c deleted file mode 100644 index 9d5787b..0000000 --- a/test/theap.c +++ /dev/null @@ -1,1081 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - Test HDF Heap routines. - - REMARKS - - DESIGN - - BUGS/LIMITATIONS - - EXPORTED ROUTINES - - AUTHOR - Quincey Koziol - - MODIFICATION HISTORY - 2/18/03 - Started coding - */ - -#include "testhdf5.h" -#include "H5HPprivate.h" - -/* The number of elements in testing arrays */ -#define NUM_ELEMS 1000 - -/* Objects for testing in heaps */ -typedef struct test_obj { - H5HP_info_t heap_info; /* Information required for heap. _MUST_ be first */ - int val; /* Actual information for object */ -} test_obj; - -/* Array of random element values */ -static test_obj *rand_num; - -/* Array of random elements values, sorted in increasing order */ -static test_obj *inc_sort_num; - -/* Array of random elements values, sorted in decreasing order */ -static test_obj *dec_sort_num; - -static int -tst_dec_sort(const void *_i1, const void *_i2) -{ - const test_obj *i1 = (const test_obj *)_i1; - const test_obj *i2 = (const test_obj *)_i2; - - if (i1->val < i2->val) - return (1); - else if (i1->val > i2->val) - return (-1); - return (0); -} - -static int -tst_inc_sort(const void *_i1, const void *_i2) -{ - const test_obj *i1 = (const test_obj *)_i1; - const test_obj *i2 = (const test_obj *)_i2; - - if (i1->val < i2->val) - return (-1); - else if (i1->val > i2->val) - return (1); - return (0); -} - -/**************************************************************** -** -** test_heap_init(): Test H5HP (heap) code. -** Initialize data for Heap testing -** -****************************************************************/ -static void -test_heap_init(void) -{ - time_t curr_time; /* Current time, for seeding random number generator */ - size_t u; /* Local index variables */ - - /* Allocate arrays */ - rand_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS); - CHECK_PTR(rand_num, "HDmalloc"); - inc_sort_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS); - CHECK_PTR(inc_sort_num, "HDmalloc"); - dec_sort_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS); - CHECK_PTR(dec_sort_num, "HDmalloc"); - - /* Create randomized set of numbers */ - curr_time = HDtime(NULL); - HDsrandom((unsigned)curr_time); - for (u = 0; u < NUM_ELEMS; u++) - /* Generate random numbers from -1000 to 1000 */ - rand_num[u].val = (int)(HDrandom() % 2001) - 1001; - - /* Sort random numbers into increasing order */ - HDmemcpy(inc_sort_num, rand_num, sizeof(test_obj) * NUM_ELEMS); - HDqsort(inc_sort_num, (size_t)NUM_ELEMS, sizeof(test_obj), tst_inc_sort); - - /* Sort random numbers into decreasing order */ - HDmemcpy(dec_sort_num, rand_num, sizeof(test_obj) * NUM_ELEMS); - HDqsort(dec_sort_num, (size_t)NUM_ELEMS, sizeof(test_obj), tst_dec_sort); -} /* end test_heap_init() */ - -/**************************************************************** -** -** test_heap_create(): Test basic H5HP (heap) code. -** Tests creating and closing heaps. -** -****************************************************************/ -static void -test_heap_create(void) -{ - H5HP_t *heap; /* Heap created */ - herr_t ret; /* Generic return value */ - - /* Output message about test being performed */ - MESSAGE(6, ("Testing Creating & Closing Heaps\n")); - - /* Try creating a maximum Heap */ - heap = H5HP_create(H5HP_MAX_HEAP); - CHECK_PTR(heap, "H5HP_create"); - - /* Try closing the heap */ - ret = H5HP_close(heap); - CHECK(ret, FAIL, "H5HP_close"); - - /* Try creating a minimum Heap */ - heap = H5HP_create(H5HP_MIN_HEAP); - CHECK_PTR(heap, "H5HP_create"); - - /* Try closing the heap */ - ret = H5HP_close(heap); - CHECK(ret, FAIL, "H5HP_close"); - -} /* end test_heap_create() */ - -/**************************************************************** -** -** test_heap_insert_min(): Test H5HP (heap) code. -** Tests basic inserting objects into minimum heaps. -** -****************************************************************/ -static void -test_heap_insert_min(void) -{ - H5HP_t * heap; /* Heap created */ - ssize_t num; /* Number of elements in heap */ - int val; /* Value of object on heap */ - test_obj obj1, obj2, obj3; /* Test objects to insert */ - herr_t ret; /* Generic return value */ - - /* Output message about test being performed */ - MESSAGE(7, ("Testing Inserting Into Minimum Heaps\n")); - - /* Create a Heap */ - heap = H5HP_create(H5HP_MIN_HEAP); - CHECK_PTR(heap, "H5HP_create"); - - /* Check that the heap has no elements */ - num = H5HP_count(heap); - VERIFY(num, 0, "H5HP_count"); - - /* Insert an object into the heap */ - obj1.val = 100; - ret = H5HP_insert(heap, 10, &obj1); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Check that the heap has one element */ - num = H5HP_count(heap); - VERIFY(num, 1, "H5HP_count"); - - /* Check the minimum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 10, "H5HP_top"); - - /* Insert another object into the heap, with value less than top element */ - obj2.val = 50; - ret = H5HP_insert(heap, 5, &obj2); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Check that the heap has two elements */ - num = H5HP_count(heap); - VERIFY(num, 2, "H5HP_count"); - - /* Check the minimum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 5, "H5HP_top"); - - /* Insert third object into the heap, with value greater than top element */ - obj3.val = 200; - ret = H5HP_insert(heap, 20, &obj3); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Check that the heap has three elements */ - num = H5HP_count(heap); - VERIFY(num, 3, "H5HP_count"); - - /* Check the minimum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 5, "H5HP_top"); - - /* Close the heap */ - ret = H5HP_close(heap); - CHECK(ret, FAIL, "H5HP_close"); - -} /* end test_heap_insert_min() */ - -/**************************************************************** -** -** test_heap_insert(): Test H5HP (heap) code. -** Tests basic inserting objects into maximum heaps. -** -****************************************************************/ -static void -test_heap_insert_max(void) -{ - H5HP_t * heap; /* Heap created */ - ssize_t num; /* Number of elements in heap */ - int val; /* Value of object on heap */ - test_obj obj1, obj2, obj3; /* Test objects to insert */ - herr_t ret; /* Generic return value */ - - /* Output message about test being performed */ - MESSAGE(7, ("Testing Inserting Into Maximum Heaps\n")); - - /* Create a Heap */ - heap = H5HP_create(H5HP_MAX_HEAP); - CHECK_PTR(heap, "H5HP_create"); - - /* Check that the heap has no elements */ - num = H5HP_count(heap); - VERIFY(num, 0, "H5HP_count"); - - /* Insert an object into the heap */ - obj1.val = 100; - ret = H5HP_insert(heap, 10, &obj1); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Check that the heap has one element */ - num = H5HP_count(heap); - VERIFY(num, 1, "H5HP_count"); - - /* Check the maximum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 10, "H5HP_top"); - - /* Insert another object into the heap, with value less than top element */ - obj2.val = 50; - ret = H5HP_insert(heap, 5, &obj2); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Check that the heap has two elements */ - num = H5HP_count(heap); - VERIFY(num, 2, "H5HP_count"); - - /* Check the maximum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 10, "H5HP_top"); - - /* Insert third object into the heap, with value greater than top element */ - obj3.val = 200; - ret = H5HP_insert(heap, 20, &obj3); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Check that the heap has three elements */ - num = H5HP_count(heap); - VERIFY(num, 3, "H5HP_count"); - - /* Check the maximum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 20, "H5HP_top"); - - /* Close the heap */ - ret = H5HP_close(heap); - CHECK(ret, FAIL, "H5HP_close"); - -} /* end test_heap_insert_max() */ - -/**************************************************************** -** -** test_heap_insert(): Test H5HP (heap) code. -** Tests basic inserting objects into heaps. -** -****************************************************************/ -static void -test_heap_insert(void) -{ - /* Output message about test being performed */ - MESSAGE(6, ("Testing Inserting Into Heaps\n")); - - /* Test insertions into minimum & maximum heaps */ - test_heap_insert_max(); - test_heap_insert_min(); -} /* end test_heap_insert() */ - -/**************************************************************** -** -** test_heap_insert_many_core (): Tests H5HP (heap) code. -** "Core" routine called by test_heap_insert_many() routine. -** -****************************************************************/ -static void -test_heap_insert_many_core(H5HP_type_t heap_type, test_obj *arr, size_t nelem, int top_val) -{ - H5HP_t *heap; /* Heap created */ - ssize_t num; /* Number of elements in heap */ - int val; /* Value of object on heap */ - size_t u; /* Local index variable */ - herr_t ret; /* Generic return value */ - - /* Create a Heap */ - heap = H5HP_create(heap_type); - CHECK_PTR(heap, "H5HP_create"); - - /* Check that the heap has no elements */ - num = H5HP_count(heap); - VERIFY(num, 0, "H5HP_count"); - - /* Insert the array elements into the heap */ - for (u = 0; u < nelem; u++) { - ret = H5HP_insert(heap, arr[u].val, &arr[u]); - CHECK(ret, FAIL, "H5HP_insert"); - } /* end for */ - - /* Check that the heap has correct number of elements */ - num = H5HP_count(heap); - CHECK(num, FAIL, "H5HP_count"); - VERIFY((size_t)num, nelem, "H5HP_count"); - - /* Check the maximum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, top_val, "H5HP_top"); - - /* Close the heap */ - ret = H5HP_close(heap); - CHECK(ret, FAIL, "H5HP_close"); -} /* end test_heap_insert_many_core() */ - -/**************************************************************** -** -** test_heap_insert_many (): Test H5HP (heap) code. -** Tests inserting many objects into heaps. -** -****************************************************************/ -static void -test_heap_insert_many(void) -{ - /* Output message about test being performed */ - MESSAGE(6, ("Testing Inserting Many Objects Into Heaps\n")); - - /* Test creating a heap from random elements */ - test_heap_insert_many_core(H5HP_MAX_HEAP, rand_num, (size_t)NUM_ELEMS, dec_sort_num[0].val); - - /* Test creating a heap from elements in increasing order */ - test_heap_insert_many_core(H5HP_MAX_HEAP, inc_sort_num, (size_t)NUM_ELEMS, dec_sort_num[0].val); - - /* Test creating a heap from elements in decreasing order */ - test_heap_insert_many_core(H5HP_MAX_HEAP, dec_sort_num, (size_t)NUM_ELEMS, dec_sort_num[0].val); - - /* Test creating a heap from random elements */ - test_heap_insert_many_core(H5HP_MIN_HEAP, rand_num, (size_t)NUM_ELEMS, inc_sort_num[0].val); - - /* Test creating a heap from elements in increasing order */ - test_heap_insert_many_core(H5HP_MIN_HEAP, inc_sort_num, (size_t)NUM_ELEMS, inc_sort_num[0].val); - - /* Test creating a heap from elements in decreasing order */ - test_heap_insert_many_core(H5HP_MIN_HEAP, dec_sort_num, (size_t)NUM_ELEMS, inc_sort_num[0].val); - -} /* end test_heap_insert_many() */ - -/**************************************************************** -** -** test_heap_remove_min(): Test H5HP (heap) code. -** Tests basic removal of objects from minimum heaps. -** -****************************************************************/ -static void -test_heap_remove_min(void) -{ - H5HP_t * heap; /* Heap created */ - ssize_t num; /* Number of elements in heap */ - int val; /* Value of object on heap */ - void * ptr; /* Pointer for object on heap */ - test_obj obj1, obj2, obj3; /* Test objects to insert */ - herr_t ret; /* Generic return value */ - - /* Output message about test being performed */ - MESSAGE(7, ("Testing Removing From Minimum Heaps\n")); - - /* Create a Heap */ - heap = H5HP_create(H5HP_MIN_HEAP); - CHECK_PTR(heap, "H5HP_create"); - - /* Check that the heap has no elements */ - num = H5HP_count(heap); - VERIFY(num, 0, "H5HP_count"); - - /* Try removing an object from an empty heap */ - ret = H5HP_remove(heap, &val, &ptr); - VERIFY(ret, FAIL, "H5HP_remove"); - - /* Insert an object into the heap */ - obj1.val = 100; - ret = H5HP_insert(heap, 10, &obj1); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Insert another object into the heap, with value less than top element */ - obj2.val = 50; - ret = H5HP_insert(heap, 5, &obj2); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Insert third object into the heap, with value greater than top element */ - obj3.val = 200; - ret = H5HP_insert(heap, 20, &obj3); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Remove first maximum value from heap */ - ret = H5HP_remove(heap, &val, &ptr); - CHECK(ret, FAIL, "H5HP_remove"); - VERIFY(val, 5, "H5HP_remove"); - CHECK_PTR_EQ(ptr, &obj2, "H5HP_remove"); - - /* Remove second maximum value from heap */ - ret = H5HP_remove(heap, &val, &ptr); - CHECK(ret, FAIL, "H5HP_remove"); - VERIFY(val, 10, "H5HP_remove"); - CHECK_PTR_EQ(ptr, &obj1, "H5HP_remove"); - - /* Remove third maximum value from heap */ - ret = H5HP_remove(heap, &val, &ptr); - CHECK(ret, FAIL, "H5HP_remove"); - VERIFY(val, 20, "H5HP_remove"); - CHECK_PTR_EQ(ptr, &obj3, "H5HP_remove"); - - /* Try removing an object from an empty heap */ - ret = H5HP_remove(heap, &val, &ptr); - VERIFY(ret, FAIL, "H5HP_remove"); - - /* Close the heap */ - ret = H5HP_close(heap); - CHECK(ret, FAIL, "H5HP_close"); - -} /* end test_heap_remove_min() */ - -/**************************************************************** -** -** test_heap_remove_max(): Test H5HP (heap) code. -** Tests basic removal of objects from maximum heaps. -** -****************************************************************/ -static void -test_heap_remove_max(void) -{ - H5HP_t * heap; /* Heap created */ - ssize_t num; /* Number of elements in heap */ - int val; /* Value of object on heap */ - void * ptr; /* Pointer for object on heap */ - test_obj obj1, obj2, obj3; /* Test objects to insert */ - herr_t ret; /* Generic return value */ - - /* Output message about test being performed */ - MESSAGE(7, ("Testing Removing From Maximum Heaps\n")); - - /* Create a Heap */ - heap = H5HP_create(H5HP_MAX_HEAP); - CHECK_PTR(heap, "H5HP_create"); - - /* Check that the heap has no elements */ - num = H5HP_count(heap); - VERIFY(num, 0, "H5HP_count"); - - /* Try removing an object from an empty heap */ - ret = H5HP_remove(heap, &val, &ptr); - VERIFY(ret, FAIL, "H5HP_remove"); - - /* Insert an object into the heap */ - obj1.val = 100; - ret = H5HP_insert(heap, 10, &obj1); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Insert another object into the heap, with value less than top element */ - obj2.val = 50; - ret = H5HP_insert(heap, 5, &obj2); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Insert third object into the heap, with value greater than top element */ - obj3.val = 200; - ret = H5HP_insert(heap, 20, &obj3); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Remove first maximum value from heap */ - ret = H5HP_remove(heap, &val, &ptr); - CHECK(ret, FAIL, "H5HP_remove"); - VERIFY(val, 20, "H5HP_remove"); - CHECK_PTR_EQ(ptr, &obj3, "H5HP_remove"); - - /* Remove second maximum value from heap */ - ret = H5HP_remove(heap, &val, &ptr); - CHECK(ret, FAIL, "H5HP_remove"); - VERIFY(val, 10, "H5HP_remove"); - CHECK_PTR_EQ(ptr, &obj1, "H5HP_remove"); - - /* Remove third maximum value from heap */ - ret = H5HP_remove(heap, &val, &ptr); - CHECK(ret, FAIL, "H5HP_remove"); - VERIFY(val, 5, "H5HP_remove"); - CHECK_PTR_EQ(ptr, &obj2, "H5HP_remove"); - - /* Try removing an object from an empty heap */ - ret = H5HP_remove(heap, &val, &ptr); - VERIFY(ret, FAIL, "H5HP_remove"); - - /* Close the heap */ - ret = H5HP_close(heap); - CHECK(ret, FAIL, "H5HP_close"); - -} /* end test_heap_remove_max() */ - -/**************************************************************** -** -** test_heap_remove(): Test H5HP (heap) code. -** Tests basic removal of objects from minimum & maximum heaps. -** -****************************************************************/ -static void -test_heap_remove(void) -{ - /* Output message about test being performed */ - MESSAGE(6, ("Testing Removing From Heaps\n")); - - /* Test removals from minimum & maximum heaps */ - test_heap_remove_max(); - test_heap_remove_min(); -} /* end test_heap_remove() */ - -/**************************************************************** -** -** test_heap_remove_many_core (): Tests H5HP (heap) code. -** "Core" routine called by test_heap_remove_many() routine. -** -****************************************************************/ -static void -test_heap_remove_many_core(H5HP_type_t heap_type, test_obj *arr, size_t nelem) -{ - H5HP_t * heap; /* Heap created */ - ssize_t num; /* Number of elements in heap */ - int last_val; /* Last value from the heap */ - int val; /* Value of object on heap */ - test_obj *ptr; /* Pointer for object on heap */ - size_t u; /* Local index variable */ - herr_t ret; /* Generic return value */ - - /* Create a Heap */ - heap = H5HP_create(heap_type); - CHECK_PTR(heap, "H5HP_create"); - - /* Check that the heap has no elements */ - num = H5HP_count(heap); - VERIFY(num, 0, "H5HP_count"); - - /* Insert the array elements into the heap */ - for (u = 0; u < nelem; u++) { - ret = H5HP_insert(heap, arr[u].val, &arr[u]); - CHECK(ret, FAIL, "H5HP_insert"); - } /* end for */ - - /* Check that the heap has correct number of elements */ - num = H5HP_count(heap); - CHECK(num, FAIL, "H5HP_count"); - VERIFY((size_t)num, nelem, "H5HP_count"); - - /* Set an appropriate starting value for the "last" value from heap */ - if (heap_type == H5HP_MAX_HEAP) - last_val = INT_MAX; - else - last_val = INT_MIN; - - /* Remove the objects from the heap */ - for (u = 0; u < nelem; u++) { - ret = H5HP_remove(heap, &val, (void **)&ptr); - CHECK(ret, FAIL, "H5HP_remove"); - VERIFY(val, ptr->val, "H5HP_remove"); - - /* Check that the value is correct, based on the heap type */ - if (heap_type == H5HP_MAX_HEAP) { - if (val > last_val) - TestErrPrintf("Error on line %d: incorrect value from heap=%d, last_val=%d\n", __LINE__, val, - last_val); - } /* end if */ - else { - if (val < last_val) - TestErrPrintf("Error on line %d: incorrect value from heap=%d, last_val=%d\n", __LINE__, val, - last_val); - } /* end else */ - - /* Update last value */ - last_val = val; - } /* end for */ - - /* Check that the heap has no elements */ - num = H5HP_count(heap); - VERIFY(num, 0, "H5HP_count"); - - /* Insert & remove again, to check that completely empty heaps can be added again */ - - /* Set an appropriate starting value for the "last" value from heap */ - if (heap_type == H5HP_MAX_HEAP) - last_val = INT_MAX; - else - last_val = INT_MIN; - - /* Insert the array elements into the heap */ - for (u = 0; u < nelem; u++) { - ret = H5HP_insert(heap, arr[u].val, &arr[u]); - CHECK(ret, FAIL, "H5HP_insert"); - } /* end for */ - - /* Check that the heap has correct number of elements */ - num = H5HP_count(heap); - CHECK(num, FAIL, "H5HP_count"); - VERIFY((size_t)num, nelem, "H5HP_count"); - - /* Remove the objects from the heap */ - for (u = 0; u < nelem; u++) { - ret = H5HP_remove(heap, &val, (void **)&ptr); - CHECK(ret, FAIL, "H5HP_remove"); - VERIFY(val, ptr->val, "H5HP_remove"); - - /* Check that the value is correct, based on the heap type */ - if (heap_type == H5HP_MAX_HEAP) { - if (val > last_val) - TestErrPrintf("Error on line %d: incorrect value from heap=%d, last_val=%d\n", __LINE__, val, - last_val); - } /* end if */ - else { - if (val < last_val) - TestErrPrintf("Error on line %d: incorrect value from heap=%d, last_val=%d\n", __LINE__, val, - last_val); - } /* end else */ - - /* Update last value */ - last_val = val; - } /* end for */ - - /* Check that the heap has no elements */ - num = H5HP_count(heap); - VERIFY(num, 0, "H5HP_count"); - - /* Close the heap */ - ret = H5HP_close(heap); - CHECK(ret, FAIL, "H5HP_close"); -} /* end test_heap_remove_many_core() */ - -/**************************************************************** -** -** test_heap_remove_many (): Test H5HP (heap) code. -** Tests removing many objects into heaps. -** -****************************************************************/ -static void -test_heap_remove_many(void) -{ - /* Output message about test being performed */ - MESSAGE(6, ("Testing Removing Many Objects From Heaps\n")); - - /* Test removing objects from maximum heap with random elements */ - test_heap_remove_many_core(H5HP_MAX_HEAP, rand_num, (size_t)NUM_ELEMS); - - /* Test removing objects from maximum heap with elements already sorted in increasing order */ - test_heap_remove_many_core(H5HP_MAX_HEAP, inc_sort_num, (size_t)NUM_ELEMS); - - /* Test removing objects from maximum heap with elements already sorted in decreasing order */ - test_heap_remove_many_core(H5HP_MAX_HEAP, dec_sort_num, (size_t)NUM_ELEMS); - - /* Test removing objects from minimum heap with random elements */ - test_heap_remove_many_core(H5HP_MIN_HEAP, rand_num, (size_t)NUM_ELEMS); - - /* Test removing objects from minimum heap with elements already sorted in increasing order */ - test_heap_remove_many_core(H5HP_MIN_HEAP, inc_sort_num, (size_t)NUM_ELEMS); - - /* Test removing objects from minimum heap with elements already sorted in decreasing order */ - test_heap_remove_many_core(H5HP_MIN_HEAP, dec_sort_num, (size_t)NUM_ELEMS); - -} /* end test_heap_remove_many() */ - -/**************************************************************** -** -** test_heap_change_min (): Test H5HP (heap) code. -** Tests changing the priority of an object in a minimum heap -** -****************************************************************/ -static void -test_heap_change_min(void) -{ - H5HP_t * heap; /* Heap created */ - ssize_t num; /* Number of elements in heap */ - int val; /* Value of object on heap */ - test_obj obj1, obj2, obj3; /* Test objects to insert */ - herr_t ret; /* Generic return value */ - - /* Output message about test being performed */ - MESSAGE(7, ("Testing Changing Priority of Objects in Minimum Heaps\n")); - - /* Create a Heap */ - heap = H5HP_create(H5HP_MIN_HEAP); - CHECK_PTR(heap, "H5HP_create"); - - /* Check that the heap has no elements */ - num = H5HP_count(heap); - VERIFY(num, 0, "H5HP_count"); - - /* Insert an object into the heap */ - obj1.val = 100; - ret = H5HP_insert(heap, 10, &obj1); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Insert another object into the heap, with value less than top element */ - obj2.val = 50; - ret = H5HP_insert(heap, 5, &obj2); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Insert third object into the heap, with value greater than top element */ - obj3.val = 200; - ret = H5HP_insert(heap, 20, &obj3); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Change priority of first object on heap in way which shouldn't affect heap order */ - ret = H5HP_change(heap, 11, &obj1); - CHECK(ret, FAIL, "H5HP_change"); - - /* Check the minimum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 5, "H5HP_top"); - - /* Change priority of first object on heap to be the top object on the heap */ - ret = H5HP_change(heap, 3, &obj1); - CHECK(ret, FAIL, "H5HP_change"); - - /* Check the maximum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 3, "H5HP_top"); - - /* Change priority of first object on heap to not be the top object on the heap */ - ret = H5HP_change(heap, 10, &obj1); - CHECK(ret, FAIL, "H5HP_change"); - - /* Check the maximum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 5, "H5HP_top"); - - /* Close the heap */ - ret = H5HP_close(heap); - CHECK(ret, FAIL, "H5HP_close"); - -} /* end test_heap_change_min() */ - -/**************************************************************** -** -** test_heap_change_max (): Test H5HP (heap) code. -** Tests changing the priority of an object in a maximumheap -** -****************************************************************/ -static void -test_heap_change_max(void) -{ - H5HP_t * heap; /* Heap created */ - ssize_t num; /* Number of elements in heap */ - int val; /* Value of object on heap */ - test_obj obj1, obj2, obj3; /* Test objects to insert */ - herr_t ret; /* Generic return value */ - - /* Output message about test being performed */ - MESSAGE(7, ("Testing Changing Priority of Objects in Maximum Heaps\n")); - - /* Create a Heap */ - heap = H5HP_create(H5HP_MAX_HEAP); - CHECK_PTR(heap, "H5HP_create"); - - /* Check that the heap has no elements */ - num = H5HP_count(heap); - VERIFY(num, 0, "H5HP_count"); - - /* Insert an object into the heap */ - obj1.val = 100; - ret = H5HP_insert(heap, 10, &obj1); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Insert another object into the heap, with value less than top element */ - obj2.val = 50; - ret = H5HP_insert(heap, 5, &obj2); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Insert third object into the heap, with value greater than top element */ - obj3.val = 200; - ret = H5HP_insert(heap, 20, &obj3); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Change priority of first object on heap in way which shouldn't affect heap order */ - ret = H5HP_change(heap, 11, &obj1); - CHECK(ret, FAIL, "H5HP_change"); - - /* Check the maximum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 20, "H5HP_top"); - - /* Change priority of first object on heap to be the top object on the heap */ - ret = H5HP_change(heap, 21, &obj1); - CHECK(ret, FAIL, "H5HP_change"); - - /* Check the maximum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 21, "H5HP_top"); - - /* Change priority of first object on heap to not be the top object on the heap */ - ret = H5HP_change(heap, 10, &obj1); - CHECK(ret, FAIL, "H5HP_change"); - - /* Check the maximum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 20, "H5HP_top"); - - /* Close the heap */ - ret = H5HP_close(heap); - CHECK(ret, FAIL, "H5HP_close"); - -} /* end test_heap_change() */ - -/**************************************************************** -** -** test_heap_change (): Test H5HP (heap) code. -** Tests changing the priority of an object in maximum & minimum heaps -** -****************************************************************/ -static void -test_heap_change(void) -{ - /* Output message about test being performed */ - MESSAGE(6, ("Testing Changing Priority of Objects in Heaps\n")); - - /* Test removals from minimum & maximum heaps */ - test_heap_change_max(); - test_heap_change_min(); -} /* end test_heap_change() */ - -/**************************************************************** -** -** test_heap_incdec_min (): Test H5HP (heap) code. -** Tests incrementing & decrementing priority of objects on -** a minimum heap. -** -****************************************************************/ -static void -test_heap_incdec_min(void) -{ - H5HP_t * heap; /* Heap created */ - ssize_t num; /* Number of elements in heap */ - int val; /* Value of object on heap */ - test_obj obj1, obj2, obj3; /* Test objects to insert */ - herr_t ret; /* Generic return value */ - - /* Output message about test being performed */ - MESSAGE(7, ("Testing Incrementing & Decrementing Priority of Objects in Minimum Heaps\n")); - - /* Create a Heap */ - heap = H5HP_create(H5HP_MIN_HEAP); - CHECK_PTR(heap, "H5HP_create"); - - /* Check that the heap has no elements */ - num = H5HP_count(heap); - VERIFY(num, 0, "H5HP_count"); - - /* Insert an object into the heap */ - obj1.val = 100; - ret = H5HP_insert(heap, 6, &obj1); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Insert another object into the heap, with value less than top element */ - obj2.val = 50; - ret = H5HP_insert(heap, 5, &obj2); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Insert third object into the heap, with value greater than top element */ - obj3.val = 200; - ret = H5HP_insert(heap, 20, &obj3); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Decrement object one's priority by two to put it on top of the heap */ - ret = H5HP_decr(heap, 2, &obj1); - CHECK(ret, FAIL, "H5HP_change"); - - /* Check the minimum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 4, "H5HP_top"); - - /* Decrement object two's priority by two to put it back on top of the heap */ - ret = H5HP_decr(heap, 2, &obj2); - CHECK(ret, FAIL, "H5HP_change"); - - /* Check the minimum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 3, "H5HP_top"); - - /* Increment object two's priority by two to return object one to the top */ - ret = H5HP_incr(heap, 2, &obj2); - CHECK(ret, FAIL, "H5HP_change"); - - /* Check the minimum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 4, "H5HP_top"); - - /* Close the heap */ - ret = H5HP_close(heap); - CHECK(ret, FAIL, "H5HP_close"); - -} /* end test_heap_incdec_min() */ - -/**************************************************************** -** -** test_heap_incdec_max (): Test H5HP (heap) code. -** Tests incrementing & decrementing priority of objects on -** a maximum heap. -** -****************************************************************/ -static void -test_heap_incdec_max(void) -{ - H5HP_t * heap; /* Heap created */ - ssize_t num; /* Number of elements in heap */ - int val; /* Value of object on heap */ - test_obj obj1, obj2, obj3; /* Test objects to insert */ - herr_t ret; /* Generic return value */ - - /* Output message about test being performed */ - MESSAGE(7, ("Testing Incrementing & Decrementing Priority of Objects in Maximum Heaps\n")); - - /* Create a Heap */ - heap = H5HP_create(H5HP_MAX_HEAP); - CHECK_PTR(heap, "H5HP_create"); - - /* Check that the heap has no elements */ - num = H5HP_count(heap); - VERIFY(num, 0, "H5HP_count"); - - /* Insert an object into the heap */ - obj1.val = 100; - ret = H5HP_insert(heap, 19, &obj1); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Insert another object into the heap, with value less than top element */ - obj2.val = 50; - ret = H5HP_insert(heap, 5, &obj2); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Insert third object into the heap, with value greater than top element */ - obj3.val = 200; - ret = H5HP_insert(heap, 20, &obj3); - CHECK(ret, FAIL, "H5HP_insert"); - - /* Increment object one's priority by two to put it on top of the heap */ - ret = H5HP_incr(heap, 2, &obj1); - CHECK(ret, FAIL, "H5HP_change"); - - /* Check the maximum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 21, "H5HP_top"); - - /* Increment object three's priority by two to put it back on top of the heap */ - ret = H5HP_incr(heap, 2, &obj3); - CHECK(ret, FAIL, "H5HP_change"); - - /* Check the maximum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 22, "H5HP_top"); - - /* Decrement object three's priority by two to return object one to the top */ - ret = H5HP_decr(heap, 2, &obj3); - CHECK(ret, FAIL, "H5HP_change"); - - /* Check the maximum value on the heap */ - ret = H5HP_top(heap, &val); - CHECK(ret, FAIL, "H5HP_top"); - VERIFY(val, 21, "H5HP_top"); - - /* Close the heap */ - ret = H5HP_close(heap); - CHECK(ret, FAIL, "H5HP_close"); - -} /* end test_heap_incdec_max() */ - -/**************************************************************** -** -** test_heap_incdec (): Test H5HP (heap) code. -** Tests incrementing & decrementing priority of objects on -** maximum & minimum heaps. -** -****************************************************************/ -static void -test_heap_incdec(void) -{ - /* Output message about test being performed */ - MESSAGE(6, ("Testing Incrementing & Decrementing Priority of Objects in Heaps\n")); - - /* Test increments & decrements in minimum & maximum heaps */ - test_heap_incdec_max(); - test_heap_incdec_min(); -} /* end test_heap_incdec() */ - -/**************************************************************** -** -** test_heap_term(): Test H5HP (heap) code. -** Release data for Heap testing -** -****************************************************************/ -static void -test_heap_term(void) -{ - /* Release arrays */ - if (rand_num) - HDfree(rand_num); - if (inc_sort_num) - HDfree(inc_sort_num); - if (dec_sort_num) - HDfree(dec_sort_num); -} /* end test_heap_term() */ - -/**************************************************************** -** -** test_heap(): Main H5HP testing routine. -** -****************************************************************/ -void -test_heap(void) -{ - /* Output message about test being performed */ - MESSAGE(5, ("Testing Heaps\n")); - - /* Initialize Heap testing data */ - test_heap_init(); - - /* Actual Heap tests */ - test_heap_create(); /* Test Heap creation */ - test_heap_insert(); /* Test basic Heap insertion */ - test_heap_insert_many(); /* Test Heap insertion of many items */ - test_heap_remove(); /* Test basic Heap removal */ - test_heap_remove_many(); /* Test Heap removal of many items */ - test_heap_change(); /* Test changing priority of objects on Heap */ - test_heap_incdec(); /* Test incrementing & decrementing priority of objects on Heap */ - - /* Release Heap testing data */ - test_heap_term(); - -} /* end test_heap() */ -- cgit v0.12 From 7a83173c7b289453e17f3026e825cb97778180cd Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Thu, 7 Apr 2022 06:01:21 -0700 Subject: Brings skip list try_free_safe changes from develop (#1612) --- src/H5SL.c | 678 +++++++++++++++++------------------------------------- src/H5SLprivate.h | 4 - test/tskiplist.c | 208 ----------------- 3 files changed, 206 insertions(+), 684 deletions(-) diff --git a/src/H5SL.c b/src/H5SL.c index 9d3f5b3..ab07a07 100644 --- a/src/H5SL.c +++ b/src/H5SL.c @@ -36,13 +36,6 @@ * skip list. The implementation in that document hurts * performance, at least for integer keys. -NAF) * - * (Also, this implementation has a couple of home-grown - * optimizations, including setting the "update" vector to the - * actual 'forward' pointer to update, instead of the node - * containing the forward pointer -QAK - * -No longer uses update vector, as insertions/deletions are now - * always at level 0. -NAF) - * * (Note: This implementation does not have the information for * implementing the "Linear List Operations" (like insert/delete/ * search by position) in section 3.4 of "A Skip List Cookbook", @@ -71,25 +64,14 @@ /* Define the code template for searches for the "OP" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_SEARCH_FOUND(SLIST, X, I) \ { \ - HDassert(!X->removed); \ - HGOTO_DONE(X->item); \ - } /* end block */ - -/* Define the code template for deferred removals for the "OP" in the - * H5SL_LOCATE macro */ -#define H5SL_LOCATE_SEARCH_DEFER_REMOVE_FOUND(SLIST, X, I) \ - { \ - HDassert(!X->removed); \ - X->removed = TRUE; \ HGOTO_DONE(X->item); \ - } /* end block */ + } /* Define the code template for finds for the "OP" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_FIND_FOUND(SLIST, X, I) \ { \ - HDassert(!X->removed); \ HGOTO_DONE(X); \ - } /* end block */ + } /* Define a code template for comparing scalar keys for the "CMP" in the H5SL_LOCATE macro */ #define H5SL_LOCATE_SCALAR_CMP(SLIST, TYPE, PNODE, PKEY, HASHVAL) (*(TYPE *)((PNODE)->key) < *(TYPE *)PKEY) @@ -155,51 +137,19 @@ H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, X->forward[_i], KEY, HASHVAL)) { \ X = X->forward[_i]; \ _count++; \ - } /* end while */ \ - } /* end for */ \ + } \ + } \ X = X->forward[0]; \ if (X != NULL && H5_GLUE3(H5SL_LOCATE_, CMP, _EQ)(SLIST, TYPE, X, KEY, HASHVAL)) { \ /* What to do when a node is found */ \ H5_GLUE3(H5SL_LOCATE_, OP, _FOUND)(SLIST, X, _i) \ - } /* end if */ \ - } - -/* Macro used to find node for operation, if there may be "removed" nodes in the - * list (whose keys cannot be read) */ -#define H5SL_LOCATE_SAFE(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ - { \ - int _i; /* Local index variable */ \ - H5SL_node_t *_low = X; \ - H5SL_node_t *_high = NULL; \ - \ - H5_GLUE3(H5SL_LOCATE_, CMP, _HASHINIT) \ - (KEY, HASHVAL) for (_i = (int)SLIST->curr_level; _i >= 0; _i--) \ - { \ - X = _low->forward[_i]; \ - while (X != _high) { \ - if (!X->removed) { \ - if (H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, X, KEY, HASHVAL)) \ - _low = X; \ - else \ - break; \ - } /* end if */ \ - X = X->forward[_i]; \ - } /* end while */ \ - _high = X; \ - if (X != NULL && H5_GLUE3(H5SL_LOCATE_, CMP, _EQ)(SLIST, TYPE, X, KEY, HASHVAL)) { \ - /* What to do when a node is found */ \ - H5_GLUE3(H5SL_LOCATE_, OP, _FOUND)(SLIST, X, _i) break; \ - } /* end if */ \ - } /* end for */ \ + } \ } /* Macro used to find node for operation */ #define H5SL_LOCATE(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ { \ - if ((SLIST)->safe_iterating) \ - H5SL_LOCATE_SAFE(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ - else \ - H5SL_LOCATE_OPT(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ + H5SL_LOCATE_OPT(OP, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ } /* Macro used to grow a node by 1. Does not update pointers. LVL is the current @@ -209,7 +159,7 @@ /* Check if we need to increase allocation of forward pointers */ \ if (LVL + 1 >= 1u << X->log_nalloc) { \ H5SL_node_t **_tmp; \ - HDassert(LVL + 1 == 1u << X->log_nalloc); \ + HDassert(LVL + 1 == 1U << X->log_nalloc); \ /* Double the amount of allocated space */ \ X->log_nalloc++; \ \ @@ -225,13 +175,13 @@ if (NULL == (H5SL_fac_g = (H5FL_fac_head_t **)H5MM_realloc( \ (void *)H5SL_fac_g, H5SL_fac_nalloc_g * sizeof(H5FL_fac_head_t *)))) \ HGOTO_ERROR(H5E_SLIST, H5E_CANTALLOC, ERR, "memory allocation failed") \ - } /* end if */ \ + } \ \ /* Create the new factory */ \ H5SL_fac_g[H5SL_fac_nused_g] = \ H5FL_fac_init((1u << H5SL_fac_nused_g) * sizeof(H5SL_node_t *)); \ H5SL_fac_nused_g++; \ - } /* end if */ \ + } \ \ /* Allocate space for new forward pointers */ \ if (NULL == (_tmp = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[X->log_nalloc]))) \ @@ -239,7 +189,7 @@ H5MM_memcpy((void *)_tmp, (const void *)X->forward, (LVL + 1) * sizeof(H5SL_node_t *)); \ X->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[X->log_nalloc - 1], (void *)X->forward); \ X->forward = _tmp; \ - } /* end if */ \ + } \ \ X->level++; \ } @@ -251,7 +201,7 @@ /* Check if we can reduce the allocation of forward pointers */ \ if (LVL <= 1u << (X->log_nalloc - 1)) { \ H5SL_node_t **_tmp; \ - HDassert(LVL == 1u << (X->log_nalloc - 1)); \ + HDassert(LVL == 1U << (X->log_nalloc - 1)); \ X->log_nalloc--; \ \ /* Allocate space for new forward pointers */ \ @@ -260,7 +210,7 @@ H5MM_memcpy((void *)_tmp, (const void *)X->forward, (LVL) * sizeof(H5SL_node_t *)); \ X->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[X->log_nalloc + 1], (void *)X->forward); \ X->forward = _tmp; \ - } /* end if */ \ + } \ \ X->level--; \ } @@ -284,12 +234,12 @@ else { \ HDassert(_lvl < (size_t)SLIST->curr_level); \ X->forward[_lvl + 1] = PREV->forward[_lvl + 1]; \ - } /* end else */ \ + } \ PREV->forward[_lvl + 1] = X; \ } /* Macro used to reduce the level of a node by 1. Does not update the head node - * "current level". PREV is the previous node of the currrent height of X. */ + * "current level". PREV is the previous node of the current height of X. */ #define H5SL_DEMOTE(X, PREV) \ { \ size_t _lvl = X->level; \ @@ -305,7 +255,7 @@ #define H5SL_INSERT(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ { \ H5SL_node_t *_last = X; /* Lowest node in the current gap */ \ - H5SL_node_t *_next = NULL; /* Highest node in the currect gap */ \ + H5SL_node_t *_next = NULL; /* Highest node in the current gap */ \ H5SL_node_t *_drop; /* Low node of the gap to drop into */ \ int _count; /* Number of nodes in the current gap */ \ int _i; \ @@ -322,7 +272,7 @@ if (!_drop) \ _drop = X; \ break; \ - } /* end if */ \ + } \ \ /* Check if this node is the start of the next gap */ \ if (!_drop && !H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, X->forward[_i], KEY, HASHVAL)) \ @@ -337,7 +287,7 @@ break; \ } \ X = X->forward[_i]; \ - } /* end for */ \ + } \ HDassert(!_drop->forward[_i] || \ !H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, _drop->forward[_i], KEY, HASHVAL)); \ \ @@ -350,7 +300,7 @@ /* Prepare to drop down */ \ X = _last = _drop; \ _next = _drop->forward[_i]; \ - } /* end for */ \ + } \ \ if (_next && H5_GLUE3(H5SL_LOCATE_, CMP, _EQ)(SLIST, TYPE, _next, KEY, HASHVAL)) \ HGOTO_ERROR(H5E_SLIST, H5E_CANTINSERT, NULL, "can't insert duplicate key") \ @@ -359,172 +309,167 @@ /* Macro used to remove node */ #define H5SL_REMOVE(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ { \ - /* Check for deferred removal */ \ - if (SLIST->safe_iterating) \ - H5SL_LOCATE(SEARCH_DEFER_REMOVE, CMP, SLIST, X, TYPE, KEY, HASHVAL) \ - else { \ - H5SL_node_t *_last = X; /* Lowest node in the current gap */ \ - H5SL_node_t *_llast = X; /* Lowest node in the previous gap */ \ - H5SL_node_t *_next = NULL; /* Highest node in the currect gap */ \ - H5SL_node_t *_drop = NULL; /* Low node of the gap to drop into */ \ - H5SL_node_t *_ldrop = NULL; /* Low node of gap before the one to drop into */ \ - H5SL_node_t *_head = SLIST->header; /* Head of the skip list */ \ - int _count; /* Number of nodes in the current gap */ \ - int _i = (int)SLIST->curr_level; \ + H5SL_node_t *_last = X; /* Lowest node in the current gap */ \ + H5SL_node_t *_llast = X; /* Lowest node in the previous gap */ \ + H5SL_node_t *_next = NULL; /* Highest node in the current gap */ \ + H5SL_node_t *_drop = NULL; /* Low node of the gap to drop into */ \ + H5SL_node_t *_ldrop = NULL; /* Low node of gap before the one to drop into */ \ + H5SL_node_t *_head = SLIST->header; /* Head of the skip list */ \ + int _count; /* Number of nodes in the current gap */ \ + int _i = (int)SLIST->curr_level; \ \ - if (_i < 0) \ - HGOTO_DONE(NULL); \ + if (_i < 0) \ + HGOTO_DONE(NULL); \ \ - H5_GLUE3(H5SL_LOCATE_, CMP, _HASHINIT) \ - (KEY, HASHVAL) \ + H5_GLUE3(H5SL_LOCATE_, CMP, _HASHINIT) \ + (KEY, HASHVAL) \ \ - /* Find the gap to drop in to at the highest level */ \ - while (X && (!X->key || H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, X, KEY, HASHVAL))) \ - { \ - _llast = _last; \ - _last = X; \ - X = X->forward[_i]; \ - } \ - _next = X; \ + /* Find the gap to drop in to at the highest level */ \ + while (X && (!X->key || H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, X, KEY, HASHVAL))) \ + { \ + _llast = _last; \ + _last = X; \ + X = X->forward[_i]; \ + } \ + _next = X; \ \ - /* Main loop */ \ - for (_i--; _i >= 0; _i--) { \ - /* Search for the node to drop into, also count the number of */ \ - /* nodes of height _i in this gap and keep track of of the node */ \ - /* before the one to drop into (_ldrop will become _llast, */ \ - /* _drop will become _last). */ \ - X = _ldrop = _last; \ - _drop = NULL; \ - for (_count = 0;; _count++) { \ - /* Terminate if this is the last node in the gap */ \ - if (X->forward[_i] == _next) { \ - if (!_drop) \ - _drop = X; \ - break; \ - } /* end if */ \ + /* Main loop */ \ + for (_i--; _i >= 0; _i--) { \ + /* Search for the node to drop into, also count the number of */ \ + /* nodes of height _i in this gap and keep track of of the node */ \ + /* before the one to drop into (_ldrop will become _llast, */ \ + /* _drop will become _last). */ \ + X = _ldrop = _last; \ + _drop = NULL; \ + for (_count = 0;; _count++) { \ + /* Terminate if this is the last node in the gap */ \ + if (X->forward[_i] == _next) { \ + if (!_drop) \ + _drop = X; \ + break; \ + } \ \ - /* If we have already found the node to drop into and there */ \ - /* is more than one node in this gap, we can stop searching */ \ - if (_drop) { \ - HDassert(_count >= 1); \ - _count = 2; \ - break; \ + /* If we have already found the node to drop into and there */ \ + /* is more than one node in this gap, we can stop searching */ \ + if (_drop) { \ + HDassert(_count >= 1); \ + _count = 2; \ + break; \ + } \ + else { /* !_drop */ \ + /* Check if this node is the start of the next gap */ \ + if (!H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, X->forward[_i], KEY, HASHVAL)) { \ + _drop = X; \ + /* Again check if we can stop searching */ \ + if (_count) { \ + _count = 2; \ + break; \ + } \ } \ - else { /* !_drop */ \ - /* Check if this node is the start of the next gap */ \ - if (!H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, X->forward[_i], KEY, HASHVAL)) { \ - _drop = X; \ - /* Again check if we can stop searching */ \ - if (_count) { \ - _count = 2; \ - break; \ - } /* end if */ \ - } /* end if */ \ - else \ - _ldrop = X; \ - } /* end else */ \ + else \ + _ldrop = X; \ + } \ \ - /* No need to check the last node in the gap if there are */ \ - /* 3, as there cannot be a fourth */ \ - if (_count == 2) { \ - if (!_drop) \ - _drop = X->forward[_i]; \ - break; \ - } /* end if */ \ - X = X->forward[_i]; \ - } /* end for */ \ - HDassert(_count >= 1 && _count <= 3); \ - HDassert(!_drop->forward[_i] || \ - !H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, _drop->forward[_i], KEY, HASHVAL)); \ + /* No need to check the last node in the gap if there are */ \ + /* 3, as there cannot be a fourth */ \ + if (_count == 2) { \ + if (!_drop) \ + _drop = X->forward[_i]; \ + break; \ + } \ + X = X->forward[_i]; \ + } \ + HDassert(_count >= 1 && _count <= 3); \ + HDassert(!_drop->forward[_i] || \ + !H5_GLUE3(H5SL_LOCATE_, CMP, _CMP)(SLIST, TYPE, _drop->forward[_i], KEY, HASHVAL)); \ \ - /* Check if we need to adjust node heights */ \ - if (_count == 1) { \ - /* Check if we are in the first gap */ \ - if (_llast == _last) { \ - /* We are in the first gap, count the number of nodes */ \ - /* of height _i in the next gap. We need only check */ \ - /* onenode to see if we should promote the first node */ \ - /* in the next gap */ \ - _llast = _next->forward[_i + 1]; \ + /* Check if we need to adjust node heights */ \ + if (_count == 1) { \ + /* Check if we are in the first gap */ \ + if (_llast == _last) { \ + /* We are in the first gap, count the number of nodes */ \ + /* of height _i in the next gap. We need only check */ \ + /* onenode to see if we should promote the first node */ \ + /* in the next gap */ \ + _llast = _next->forward[_i + 1]; \ \ - /* Demote the separator node */ \ - H5SL_DEMOTE(_next, _last) \ + /* Demote the separator node */ \ + H5SL_DEMOTE(_next, _last) \ \ - /* If there are 2 or more nodes, promote the first */ \ - if (_next->forward[_i]->forward[_i] != _llast) { \ - X = _next->forward[_i]; \ - H5SL_PROMOTE(SLIST, X, _last, NULL) \ - } \ - else if (!_head->forward[_i + 1]) { \ - /* shrink the header */ \ - HDassert(_i == SLIST->curr_level - 1); \ - HDassert((size_t)SLIST->curr_level == _head->level); \ + /* If there are 2 or more nodes, promote the first */ \ + if (_next->forward[_i]->forward[_i] != _llast) { \ + X = _next->forward[_i]; \ + H5SL_PROMOTE(SLIST, X, _last, NULL) \ + } \ + else if (!_head->forward[_i + 1]) { \ + /* shrink the header */ \ + HDassert(_i == SLIST->curr_level - 1); \ + HDassert((size_t)SLIST->curr_level == _head->level); \ \ - H5SL_SHRINK(_head, (size_t)(_i + 1)) \ - SLIST->curr_level--; \ - } /* end else */ \ + H5SL_SHRINK(_head, (size_t)(_i + 1)) \ + SLIST->curr_level--; \ } \ - else { \ - /* We are not in the first gap, count the number of */ \ - /* nodes of height _i in the previous gap. Note we */ \ - /* "look ahead" in this loop so X has the value of the */ \ - /* last node in the previous gap. */ \ - X = _llast->forward[_i]; \ - for (_count = 1; _count < 3 && X->forward[_i] != _last; _count++) \ - X = X->forward[_i]; \ - HDassert(X->forward[_i] == _last); \ + } \ + else { \ + /* We are not in the first gap, count the number of */ \ + /* nodes of height _i in the previous gap. Note we */ \ + /* "look ahead" in this loop so X has the value of the */ \ + /* last node in the previous gap. */ \ + X = _llast->forward[_i]; \ + for (_count = 1; _count < 3 && X->forward[_i] != _last; _count++) \ + X = X->forward[_i]; \ + HDassert(X->forward[_i] == _last); \ \ - /* Demote the separator node */ \ - H5SL_DEMOTE(_last, _llast) \ + /* Demote the separator node */ \ + H5SL_DEMOTE(_last, _llast) \ \ - /* If there are 2 or more nodes, promote the last */ \ - if (_count >= 2) \ - H5SL_PROMOTE(SLIST, X, _llast, NULL) \ - else if (!_head->forward[_i + 1]) { \ - /* shrink the header */ \ - HDassert(_i == SLIST->curr_level - 1); \ - HDassert((size_t)SLIST->curr_level == _head->level); \ + /* If there are 2 or more nodes, promote the last */ \ + if (_count >= 2) \ + H5SL_PROMOTE(SLIST, X, _llast, NULL) \ + else if (!_head->forward[_i + 1]) { \ + /* shrink the header */ \ + HDassert(_i == SLIST->curr_level - 1); \ + HDassert((size_t)SLIST->curr_level == _head->level); \ \ - H5SL_SHRINK(_head, (size_t)(_i + 1)) \ - SLIST->curr_level--; \ - } /* end else */ \ - } /* end else */ \ - } /* end if */ \ + H5SL_SHRINK(_head, (size_t)(_i + 1)) \ + SLIST->curr_level--; \ + } \ + } \ + } \ \ - /* Prepare to drop down */ \ - _llast = _ldrop; \ - _last = _drop; \ - _next = _drop->forward[_i]; \ - } /* end for */ \ + /* Prepare to drop down */ \ + _llast = _ldrop; \ + _last = _drop; \ + _next = _drop->forward[_i]; \ + } \ \ - /* Check if we've found the node */ \ - if (_next && H5_GLUE3(H5SL_LOCATE_, CMP, _EQ)(SLIST, TYPE, _next, KEY, HASHVAL)) { \ - void *tmp = _next->item; \ - X = _next; \ + /* Check if we've found the node */ \ + if (_next && H5_GLUE3(H5SL_LOCATE_, CMP, _EQ)(SLIST, TYPE, _next, KEY, HASHVAL)) { \ + void *tmp = _next->item; \ + X = _next; \ \ - /* If the node has a height > 0, swap it with its (lower) */ \ - /* neighbor */ \ - if (X->level) { \ - X = X->backward; \ - _next->key = X->key; \ - _next->item = X->item; \ - _next->hashval = X->hashval; \ - } /* end if */ \ - HDassert(!X->level); \ + /* If the node has a height > 0, swap it with its (lower) */ \ + /* neighbor */ \ + if (X->level) { \ + X = X->backward; \ + _next->key = X->key; \ + _next->item = X->item; \ + _next->hashval = X->hashval; \ + } \ + HDassert(!X->level); \ \ - /* Remove the node */ \ - X->backward->forward[0] = X->forward[0]; \ - if (SLIST->last == X) \ - SLIST->last = X->backward; \ - else \ - X->forward[0]->backward = X->backward; \ - SLIST->nobjs--; \ - X->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[0], X->forward); \ - X = H5FL_FREE(H5SL_node_t, X); \ + /* Remove the node */ \ + X->backward->forward[0] = X->forward[0]; \ + if (SLIST->last == X) \ + SLIST->last = X->backward; \ + else \ + X->forward[0]->backward = X->backward; \ + SLIST->nobjs--; \ + X->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[0], X->forward); \ + X = H5FL_FREE(H5SL_node_t, X); \ \ - HGOTO_DONE(tmp); \ - } /* end if */ \ - } /* end else */ \ + HGOTO_DONE(tmp); \ + } \ } /* Macro used to search for node */ @@ -542,7 +487,6 @@ struct H5SL_node_t { size_t level; /* The level of this node */ size_t log_nalloc; /* log2(Number of slots allocated in forward) */ uint32_t hashval; /* Hash value for key (only for strings, currently) */ - hbool_t removed; /* Whether the node is "removed" (actual removal deferred) */ struct H5SL_node_t **forward; /* Array of forward pointers from this node */ struct H5SL_node_t * backward; /* Backward pointer from this node */ }; @@ -558,8 +502,6 @@ struct H5SL_t { size_t nobjs; /* Number of active objects in skip list */ H5SL_node_t *header; /* Header for nodes in skip list */ H5SL_node_t *last; /* Pointer to last node in skip list */ - hbool_t safe_iterating; /* Whether a routine is "safely" iterating over the list and removals should be - deferred */ }; /* Static functions */ @@ -651,11 +593,11 @@ H5SL_term_package(void) for (i = 0; i < H5SL_fac_nused_g; i++) { ret = H5FL_fac_term(H5SL_fac_g[i]); HDassert(ret >= 0); - } /* end if */ + } H5SL_fac_nused_g = 0; n++; - } /* end if */ + } /* Free the list of factories */ if (H5SL_fac_g) { @@ -663,12 +605,12 @@ H5SL_term_package(void) H5SL_fac_nalloc_g = 0; n++; - } /* end if */ + } /* Mark the interface as uninitialized */ if (0 == n) H5_PKG_INIT_VAR = FALSE; - } /* end if */ + } FUNC_LEAVE_NOAPI(n) } /* H5SL_term_package() */ @@ -711,11 +653,10 @@ H5SL__new_node(void *item, const void *key, uint32_t hashval) ret_value->item = item; ret_value->level = 0; ret_value->hashval = hashval; - ret_value->removed = FALSE; if (NULL == (ret_value->forward = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[0]))) { ret_value = H5FL_FREE(H5SL_node_t, ret_value); HGOTO_ERROR(H5E_SLIST, H5E_NOSPACE, NULL, "memory allocation failed") - } /* end if */ + } ret_value->log_nalloc = 0; done: @@ -805,7 +746,7 @@ H5SL__insert_common(H5SL_t *slist, void *item, const void *key) default: HDassert(0 && "Unknown skiplist type!"); - } /* end switch */ + } /* 'key' must not have been found in existing list, if we get here */ @@ -880,15 +821,22 @@ H5SL__release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) while (node) { next_node = node->forward[0]; - /* Call callback, if one is given */ + /* Call callback, if one is given. + * + * Ignoring const here is fine as we only need the value to be const + * with respect to the list code, which should never modify the + * elements. The library code that is making use of the skip list + * container can do what it likes with the elements. + */ + H5_GCC_DIAG_OFF("cast-qual") if (op) - /* Casting away const OK -QAK */ (void)(op)(node->item, (void *)node->key, op_data); + H5_GCC_DIAG_ON("cast-qual") node->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[node->log_nalloc], node->forward); node = H5FL_FREE(H5SL_node_t, node); node = next_node; - } /* end while */ + } /* Reset the header pointers */ slist->header->forward = @@ -1001,9 +949,8 @@ H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp) new_slist->cmp = cmp; /* Set the dynamic internal fields */ - new_slist->curr_level = -1; - new_slist->nobjs = 0; - new_slist->safe_iterating = FALSE; + new_slist->curr_level = -1; + new_slist->nobjs = 0; /* Allocate the header node */ if (NULL == (header = H5SL__new_node(NULL, NULL, (uint32_t)ULONG_MAX))) @@ -1027,7 +974,7 @@ done: if (ret_value == NULL) { if (new_slist != NULL) new_slist = H5FL_FREE(H5SL_t, new_slist); - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_create() */ @@ -1058,9 +1005,6 @@ H5SL_count(H5SL_t *slist) /* Check args */ HDassert(slist); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -1099,9 +1043,6 @@ H5SL_insert(H5SL_t *slist, void *item, const void *key) HDassert(slist); HDassert(key); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -1148,9 +1089,6 @@ H5SL_add(H5SL_t *slist, void *item, const void *key) HDassert(slist); HDassert(key); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -1242,7 +1180,7 @@ H5SL_remove(H5SL_t *slist, const void *key) default: HDassert(0 && "Unknown skiplist type!"); - } /* end switch */ + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1281,9 +1219,6 @@ H5SL_remove_first(H5SL_t *slist) /* Check args */ HDassert(slist); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Assign level */ H5_CHECK_OVERFLOW(slist->curr_level, int, size_t); level = (size_t)slist->curr_level; @@ -1345,12 +1280,12 @@ H5SL_remove_first(H5SL_t *slist) H5SL_SHRINK(head, level) slist->curr_level--; - } /* end else */ + } } else break; - } /* end for */ - } /* end if */ + } + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1436,7 +1371,7 @@ H5SL_search(H5SL_t *slist, const void *key) default: HDassert(0 && "Unknown skiplist type!"); - } /* end switch */ + } /* 'key' must not have been found in list, if we get here */ ret_value = NULL; @@ -1480,9 +1415,6 @@ H5SL_less(H5SL_t *slist, const void *key) HDassert(slist); HDassert(key); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -1531,7 +1463,7 @@ H5SL_less(H5SL_t *slist, const void *key) default: HDassert(0 && "Unknown skiplist type!"); - } /* end switch */ + } /* An exact match for 'key' must not have been found in list, if we get here */ /* Check for a node with a key that is less than the given 'key' */ @@ -1541,13 +1473,13 @@ H5SL_less(H5SL_t *slist, const void *key) ret_value = slist->last->item; else ret_value = NULL; - } /* end if */ + } else { if (x->backward != slist->header) ret_value = x->backward->item; else ret_value = NULL; - } /* end else */ + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1588,9 +1520,6 @@ H5SL_greater(H5SL_t *slist, const void *key) HDassert(slist); HDassert(key); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -1639,7 +1568,7 @@ H5SL_greater(H5SL_t *slist, const void *key) default: HDassert(0 && "Unknown skiplist type!"); - } /* end switch */ + } /* An exact match for 'key' must not have been found in list, if we get here */ /* ('x' must be the next node with a key greater than the 'key', or NULL) */ @@ -1734,7 +1663,7 @@ H5SL_find(H5SL_t *slist, const void *key) default: HDassert(0 && "Unknown skiplist type!"); - } /* end switch */ + } /* 'key' must not have been found in list, if we get here */ ret_value = NULL; @@ -1826,7 +1755,7 @@ H5SL_below(H5SL_t *slist, const void *key) default: HDassert(0 && "Unknown skiplist type!"); - } /* end switch */ + } /* An exact match for 'key' must not have been found in list, if we get here */ /* Check for a node with a key that is less than the given 'key' */ @@ -1836,13 +1765,13 @@ H5SL_below(H5SL_t *slist, const void *key) ret_value = slist->last; else ret_value = NULL; - } /* end if */ + } else { if (x->backward != slist->header) ret_value = x->backward; else ret_value = NULL; - } /* end else */ + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1931,7 +1860,7 @@ H5SL_above(H5SL_t *slist, const void *key) default: HDassert(0 && "Unknown skiplist type!"); - } /* end switch */ + } /* An exact match for 'key' must not have been found in list, if we get here */ /* ('x' must be the next node with a key greater than the 'key', or NULL) */ @@ -1971,9 +1900,6 @@ H5SL_first(H5SL_t *slist) /* Check args */ HDassert(slist); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -2007,9 +1933,6 @@ H5SL_next(H5SL_node_t *slist_node) /* Check args */ HDassert(slist_node); - /* Not currently supported */ - HDassert(!slist_node->removed); - /* Check internal consistency */ /* (Pre-condition) */ @@ -2020,7 +1943,7 @@ H5SL_next(H5SL_node_t *slist_node) NAME H5SL_prev PURPOSE - Gets a pointer to the previos node in a skip list + Gets a pointer to the previous node in a skip list USAGE H5SL_node_t *H5SL_prev(slist_node) H5SL_node_t *slist_node; IN: Pointer to skip list node @@ -2043,9 +1966,6 @@ H5SL_prev(H5SL_node_t *slist_node) /* Check args */ HDassert(slist_node); - /* Not currently supported */ - HDassert(!slist_node->removed); - /* Check internal consistency */ /* (Pre-condition) */ @@ -2080,9 +2000,6 @@ H5SL_last(H5SL_t *slist) /* Check args */ HDassert(slist); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -2116,9 +2033,6 @@ H5SL_item(H5SL_node_t *slist_node) /* Check args */ HDassert(slist_node); - /* Not currently supported */ - HDassert(!slist_node->removed); - /* Check internal consistency */ /* (Pre-condition) */ @@ -2179,15 +2093,21 @@ H5SL_iterate(H5SL_t *slist, H5SL_operator_t op, void *op_data) /* Protect against the node being deleted by the callback */ next = node->forward[0]; - /* Call the iterator callback */ - /* Casting away const OK -QAK */ - if (!node->removed) - if ((ret_value = (op)(node->item, (void *)node->key, op_data)) != 0) - break; + /* Call the iterator callback + * + * Ignoring const here is fine as we only need the value to be const + * with respect to the list code, which should never modify the + * elements. The library code that is making use of the skip list + * container can do what it likes with the elements. + */ + H5_GCC_DIAG_OFF("cast-qual") + if ((ret_value = (op)(node->item, (void *)node->key, op_data)) != 0) + break; + H5_GCC_DIAG_ON("cast-qual") /* Advance to next node */ node = next; - } /* end while */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_iterate() */ @@ -2222,9 +2142,6 @@ H5SL_release(H5SL_t *slist) /* Check args */ HDassert(slist); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -2233,7 +2150,7 @@ H5SL_release(H5SL_t *slist) HGOTO_ERROR(H5E_SLIST, H5E_CANTFREE, FAIL, "can't release skip list nodes") done: - FUNC_LEAVE_NOAPI(SUCCEED) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_release() */ /*-------------------------------------------------------------------------- @@ -2274,9 +2191,6 @@ H5SL_free(H5SL_t *slist, H5SL_operator_t op, void *op_data) /* Check args */ HDassert(slist); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -2290,186 +2204,6 @@ done: /*-------------------------------------------------------------------------- NAME - H5SL_try_free_safe - PURPOSE - Makes the supplied callback on all nodes in the skip list, freeing each - node that the callback returns TRUE for. - USAGE - herr_t PURPOSE(slist,op,opdata) - H5SL_t *slist; IN/OUT: Pointer to skip list to release nodes - H5SL_try_free_op_t op; IN: Callback function to try to free item & key - void *op_data; IN/OUT: Pointer to application data for callback - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Makes the supplied callback on all nodes in the skip list, freeing each - node that the callback returns TRUE for. The iteration is performed in - a safe manner, such that the callback can call H5SL_remove(), - H5SL_search(), H5SL_find(), and H5SL_iterate() on nodes in this - skiplist, except H5SL_remove() may not be call on *this* node. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This function is written to be most efficient when most nodes are - removed from the skiplist, as it rebuilds the nodes afterwards. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, void *op_data) -{ - H5SL_node_t *node, *next_node, *last_node; /* Pointers to skip list nodes */ - htri_t op_ret; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - /* Check args */ - HDassert(slist); - HDassert(op); - - /* Not currently supported */ - HDassert(!slist->safe_iterating); - - /* Check internal consistency */ - /* (Pre-condition) */ - - /* Mark skip list as safe iterating, so nodes aren't freed out from under - * us */ - slist->safe_iterating = TRUE; - - /* Iterate over skip list nodes, making the callback for each and marking - * them as removed if requested by the callback */ - node = slist->header->forward[0]; - while (node) { - /* Check if the node was already removed */ - if (!node->removed) { - /* Call callback */ - /* Casting away const OK -NAF */ - if ((op_ret = (op)(node->item, (void *)node->key, op_data)) < 0) - HGOTO_ERROR(H5E_SLIST, H5E_CALLBACK, FAIL, "callback operation failed") - - /* Check if op indicated that the node should be removed */ - if (op_ret) - /* Mark the node as removed */ - node->removed = TRUE; - } /* end if */ - - /* Advance node */ - node = node->forward[0]; - } /* end while */ - - /* Reset safe_iterating */ - slist->safe_iterating = FALSE; - - /* Iterate over nodes, freeing ones marked as removed */ - node = slist->header->forward[0]; - last_node = slist->header; - while (node) { - /* Save next node */ - next_node = node->forward[0]; - - /* Check if the node was marked as removed */ - if (node->removed) { - /* Remove the node */ - node->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[node->log_nalloc], node->forward); - node = H5FL_FREE(H5SL_node_t, node); - slist->nobjs--; - } /* end if */ - else { - /* Update backwards and forwards[0] pointers, and set the level to - * 0. Since the list is flattened we must rebuild the skiplist - * afterwards. */ - /* Set level to 0. Note there is no need to preserve - * node->forward[0] since it was cached above and will always be - * updated later. */ - if (node->level > 0) { - node->forward = - (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[node->log_nalloc], (void *)node->forward); - if (NULL == (node->forward = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[0]))) - HGOTO_ERROR(H5E_SLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") - node->log_nalloc = 0; - node->level = 0; - } /* end if */ - - /* Update pointers */ - last_node->forward[0] = node; - node->backward = last_node; - last_node = node; - } /* end else */ - - /* Advance node */ - node = next_node; - } /* end while */ - - /* Final pointer update */ - last_node->forward[0] = NULL; - slist->last = last_node; - - /* Demote skip list to level 0 */ - if (slist->curr_level > 0) { - HDassert(slist->header->level == (size_t)slist->curr_level); - - node = slist->header->forward[0]; - slist->header->forward = (H5SL_node_t **)H5FL_FAC_FREE(H5SL_fac_g[slist->header->log_nalloc], - (void *)slist->header->forward); - if (NULL == (slist->header->forward = (H5SL_node_t **)H5FL_FAC_MALLOC(H5SL_fac_g[0]))) - HGOTO_ERROR(H5E_SLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") - slist->header->forward[0] = node; - slist->header->log_nalloc = 0; - slist->header->level = 0; - } /* end if */ - - /* Check if there are any nodes left */ - if (slist->nobjs > 0) { - int i; - - HDassert(slist->header->forward[0]); - - /* Set skiplist level to 0 */ - slist->curr_level = 0; - - /* Rebuild the forward arrays */ - for (i = 0; slist->curr_level >= i; i++) { - HDassert(slist->curr_level == i); - - /* Promote every third node this level until we run out of nodes */ - node = last_node = slist->header; - while (1) { - /* Check second node in gap, if not present, no need to promote - * further this level. */ - HDassert(node->forward[i]); - node = node->forward[i]->forward[i]; - if (!node) - break; - - /* Check third and fourth node in gap, if either is not present, - * no need to promote further this level. */ - node = node->forward[i]; - if (!node || !node->forward[i]) - break; - - /* Promote the third node in the gap */ - H5SL_PROMOTE(slist, node, last_node, FAIL) - last_node = node; - } /* end while */ - } /* end for */ - } /* end if */ - else { - HDassert(!slist->header->forward[0]); - HDassert(slist->last == slist->header); - HDassert(slist->nobjs == 0); - - /* Reset the skiplist level */ - slist->curr_level = -1; - } /* end else */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5SL_try_free_safe() */ - -/*-------------------------------------------------------------------------- - NAME H5SL_destroy PURPOSE Close a skip list, deallocating it and freeing all its nodes. diff --git a/src/H5SLprivate.h b/src/H5SLprivate.h index c9e1147..be6f7b6 100644 --- a/src/H5SLprivate.h +++ b/src/H5SLprivate.h @@ -60,9 +60,6 @@ typedef int (*H5SL_cmp_t)(const void *key1, const void *key2); /* Typedef for iteration operations */ typedef herr_t (*H5SL_operator_t)(void *item, void *key, void *operator_data /*in,out*/); -/* Typedef for H5SL_try_free_safe operation callback */ -typedef htri_t (*H5SL_try_free_op_t)(void *item, void *key, void *operator_data /*in,out*/); - /********************/ /* Private routines */ /********************/ @@ -86,7 +83,6 @@ H5_DLL void * H5SL_item(H5SL_node_t *slist_node); H5_DLL herr_t H5SL_iterate(H5SL_t *slist, H5SL_operator_t op, void *op_data); H5_DLL herr_t H5SL_release(H5SL_t *slist); H5_DLL herr_t H5SL_free(H5SL_t *slist, H5SL_operator_t op, void *op_data); -H5_DLL herr_t H5SL_try_free_safe(H5SL_t *slist, H5SL_try_free_op_t op, void *op_data); H5_DLL herr_t H5SL_close(H5SL_t *slist); H5_DLL herr_t H5SL_destroy(H5SL_t *slist, H5SL_operator_t op, void *op_data); H5_DLL int H5SL_term_interface(void); diff --git a/test/tskiplist.c b/test/tskiplist.c index 4bf9b11..31b5cff 100644 --- a/test/tskiplist.c +++ b/test/tskiplist.c @@ -1165,213 +1165,6 @@ test_skiplist_free(void) /**************************************************************** ** -** test_skiplist_try_free_safe(): Test H5SL (skip list) code. -** Tests 'try_free_safe' operation in skip lists. -** -****************************************************************/ -/* Macro definitions */ -#define TEST_TFS_MAX_NOBJS 100 -#define TEST_TFS_MIN_NOBJS 5 -#define TEST_TFS_NITER 50 - -/* Structure to hold the list of objects */ -typedef struct { - H5SL_t * slist; /* Skiplist holding the objects */ - struct test_tfs_obj_t *list; /* Linear list of objects */ - int nobjs; /* Number of objects in list */ - int nobjs_rem; /* Number of objects in list that have not been freed */ -} test_tfs_list_t; - -/* Structure for an object */ -typedef struct test_tfs_obj_t { - int idx; /* Index (key) for this object */ - int nfrees; /* Number of times this object has been freed */ -} test_tfs_obj_t; - -/* op_data struct for H5SL_iterate() */ -typedef struct test_tfs_it_ud_t { - test_tfs_list_t *obj_list; /* List of objects */ - int last_idx; /* Index of last object visited in iteration */ - int ncalls; /* Number of times this callback was called */ -} test_tfs_it_ud_t; - -/* iterate callback */ -static herr_t -test_tfs_iter(void *_obj, void *key, void *_udata) -{ - test_tfs_obj_t * obj = (test_tfs_obj_t *)_obj; - test_tfs_it_ud_t *udata = (test_tfs_it_ud_t *)_udata; - - /* Check consistency */ - CHECK_PTR_EQ((void *)&obj->idx, key, "obj->idx"); - CHECK_PTR_EQ(obj, &udata->obj_list->list[obj->idx], "obj_list->list[obj->idx]"); - - /* Increment number of calls */ - udata->ncalls++; - - /* Verify we were given the correct object */ - do { - udata->last_idx++; - } while (udata->obj_list->list[udata->last_idx].nfrees != 0); - VERIFY(udata->last_idx, obj->idx, "H5SL_iterate"); - - return 0; -} /* end test_tfs_iter() */ - -/* try_free_safe callback */ -static htri_t -test_tfs_free(void *_obj, void *key, void *_obj_list) -{ - test_tfs_obj_t * obj = (test_tfs_obj_t *)_obj; - test_tfs_list_t *obj_list = (test_tfs_list_t *)_obj_list; - test_tfs_it_ud_t iter_ud; - int nrems, rem_idx, i, j; - test_tfs_obj_t * obj_ret; - herr_t ret; /* return value */ - htri_t ret_value; - - /* Check consistency */ - CHECK_PTR_EQ((void *)&obj->idx, key, "obj->idx"); - CHECK_PTR_EQ(obj, &obj_list->list[obj->idx], "obj_list->list[obj->idx]"); - - /* Mark this object as freed (to make sure it isn't recursively freed, that - * is not something we support, we will undo this if we decide later not to - * free the object) */ - obj->nfrees++; - obj_list->nobjs_rem--; - - /* Decide how many objects to remove */ - nrems = (int)(HDrandom() % (long)3); - - /* Remove objects */ - for (i = 0; i < nrems; i++) - /* Check nobjs_rem */ - if (obj_list->nobjs_rem > 0) { - /* Remove a random object from the list */ - rem_idx = (int)(HDrandom() % (long)obj_list->nobjs_rem); - - /* Scan the list, finding the rem_idx'th object that has not been - * freed */ - for (j = 0; j < obj_list->nobjs; j++) - if (obj_list->list[j].nfrees == 0) { - if (rem_idx == 0) - break; - else - rem_idx--; - } /* end if */ - if (j == obj_list->nobjs) - ERROR("invalid obj_list"); - else { - /* Remove the object */ - obj_ret = (test_tfs_obj_t *)H5SL_remove(obj_list->slist, &j); - CHECK_PTR(obj_ret, "H5SL_remove"); - obj_ret->nfrees++; - obj_list->nobjs_rem--; - } /* end else */ - } /* end if */ - - /* Mark this object as not freed so we know to expect it in the iterate call - */ - obj->nfrees--; - obj_list->nobjs_rem++; - - /* Iterate over skip list (maybe) */ - if (HDrandom() % (long)5) { - iter_ud.obj_list = obj_list; - iter_ud.last_idx = -1; - iter_ud.ncalls = 0; - ret = H5SL_iterate(obj_list->slist, test_tfs_iter, &iter_ud); - CHECK(ret, FAIL, "H5SL_iterate"); - VERIFY(iter_ud.ncalls, obj_list->nobjs_rem, "H5SL_iterate"); - } /* end if */ - - /* Verify nobjs_rem is non-negative */ - if (obj_list->nobjs_rem < 0) - ERROR("invalid nobjs_rem"); - - /* Decide whether this object should be freed */ - if (HDrandom() % (long)2) { - /* Free the object */ - ret_value = TRUE; - obj->nfrees++; - obj_list->nobjs_rem--; - } /* end if */ - else - /* Do not free the object */ - ret_value = FALSE; - - return ret_value; -} /* end test_tfs_free() */ - -/* Test function */ -static void -test_skiplist_try_free_safe(void) -{ - test_tfs_list_t obj_list; - test_tfs_obj_t list[TEST_TFS_MAX_NOBJS]; - int i, j; - int nobjs_found; - hsize_t count; - herr_t ret; /* Generic return value */ - - /* Output message about test being performed */ - MESSAGE(7, ("Testing Skip List 'Try Free Safe' Operation\n")); - - /* Create a skip list */ - obj_list.slist = H5SL_create(H5SL_TYPE_INT, NULL); - CHECK_PTR(obj_list.slist, "H5SL_create"); - - /* Init obj_list.list */ - obj_list.list = list; - for (j = 0; j < TEST_TFS_MAX_NOBJS; j++) - list[j].idx = j; - - for (i = 0; i < TEST_TFS_NITER; i++) { - /* Build object list */ - obj_list.nobjs = obj_list.nobjs_rem = - (int)(TEST_TFS_MIN_NOBJS + (HDrandom() % (long)(TEST_TFS_MAX_NOBJS - TEST_TFS_MIN_NOBJS + 1))); - for (j = 0; j < obj_list.nobjs; j++) { - list[j].nfrees = 0; - ret = H5SL_insert(obj_list.slist, &list[j], &list[j].idx); - CHECK(ret, FAIL, "H5SL_insert"); - } /* end for */ - - /* Call H5S_try_free_safe() - free most of the items in the skip list in - * a safe manner */ - ret = H5SL_try_free_safe(obj_list.slist, test_tfs_free, &obj_list); - CHECK(ret, FAIL, "H5SL_try_free_safe"); - - /* Verify list */ - nobjs_found = 0; - for (j = 0; j < obj_list.nobjs; j++) - if (list[j].nfrees == 0) - nobjs_found++; - else - VERIFY(list[j].nfrees, (long)1, "list[j].nfrees"); - - /* Verify number of objects */ - VERIFY(obj_list.nobjs_rem, nobjs_found, "obj_list.nobjs_rem"); - count = H5SL_count(obj_list.slist); - VERIFY(count, (size_t)nobjs_found, "H5SL_count"); - - /* Release the skip list, forcibly freeing all nodes (will not make - * callbacks) */ - ret = H5SL_release(obj_list.slist); - CHECK(ret, FAIL, "H5SL_release"); - - /* Verify number of objects is 0 */ - count = H5SL_count(obj_list.slist); - VERIFY(count, (size_t)0, "H5SL_count"); - } /* end for */ - - /* Close the skip list */ - ret = H5SL_close(obj_list.slist); - CHECK(ret, FAIL, "H5SL_close"); - -} /* end test_skiplist_try_free_safe() */ - -/**************************************************************** -** ** test_skiplist_less(): Test H5SL (skip list) code. ** Tests 'less' operation in skip lists. ** @@ -1796,7 +1589,6 @@ test_skiplist(void) test_skiplist_add(); /* Test 'add' operation */ test_skiplist_destroy(); /* Test 'destroy' operation */ test_skiplist_free(); /* Test 'free' operation */ - test_skiplist_try_free_safe(); /* Test 'try_free_safe' operation */ test_skiplist_less(); /* Test 'less' operation */ test_skiplist_greater(); /* Test 'greater' operation */ test_skiplist_below(); /* Test 'below' operation */ -- cgit v0.12 From 65568d75746b56ce7066337cf4c5c4aad11ff5f9 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Thu, 7 Apr 2022 06:01:44 -0700 Subject: Normalization of HL library with develop (#1609) --- hl/examples/ex_image1.c | 4 +- hl/src/H5DO.c | 2 +- hl/src/H5DS.c | 8 +-- hl/src/H5LT.c | 60 ++++++++++++++++++--- hl/src/H5LTpublic.h | 6 +++ hl/test/test_ds.c | 28 +++++----- hl/test/test_file_image.c | 2 +- hl/test/test_h5do_compat.c | 2 +- hl/test/test_image.c | 4 +- hl/test/test_ld.c | 6 +-- hl/test/test_lite.c | 109 +++++++++++++++++++++++++++------------ hl/test/test_packet_vlen.c | 2 +- hl/test/test_table.c | 2 +- hl/tools/gif2h5/decompress.c | 4 +- hl/tools/gif2h5/gif2mem.c | 34 ++++++------ hl/tools/gif2h5/gifread.c | 44 ++++++++-------- hl/tools/gif2h5/h52giftest.sh.in | 2 +- hl/tools/gif2h5/hdfgifwr.c | 14 ++--- hl/tools/gif2h5/writehdf.c | 4 +- hl/tools/h5watch/extend_dset.c | 4 +- 20 files changed, 219 insertions(+), 122 deletions(-) diff --git a/hl/examples/ex_image1.c b/hl/examples/ex_image1.c index ead1715..1294ab3 100644 --- a/hl/examples/ex_image1.c +++ b/hl/examples/ex_image1.c @@ -56,10 +56,10 @@ main(void) H5IMmake_image_8bit(file_id, "image1", (hsize_t)WIDTH, (hsize_t)HEIGHT, buf); /* make a palette */ - H5IMmake_palette(file_id, "pallete", pal_dims, pal); + H5IMmake_palette(file_id, "palette", pal_dims, pal); /* attach the palette to the image */ - H5IMlink_palette(file_id, "image1", "pallete"); + H5IMlink_palette(file_id, "image1", "palette"); /* close the file. */ H5Fclose(file_id); diff --git a/hl/src/H5DO.c b/hl/src/H5DO.c index 3bdb4e2..1703669 100644 --- a/hl/src/H5DO.c +++ b/hl/src/H5DO.c @@ -182,7 +182,7 @@ H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension, hid_t if (FAIL == H5Sselect_hyperslab(new_space_id, H5S_SELECT_SET, start, stride, count, block)) goto done; - /* The # of elemnts in the new extended dataspace */ + /* The # of elements in the new extended dataspace */ if ((snelmts = H5Sget_select_npoints(new_space_id)) < 0) goto done; nelmts = (hsize_t)snelmts; diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index c947d16..387419b 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -88,7 +88,7 @@ H5DSset_scale(hid_t dsid, const char *dimname) return FAIL; /*------------------------------------------------------------------------- - * check if the dataset is a dataset wich has references to dimension scales + * check if the dataset is a dataset which has references to dimension scales *------------------------------------------------------------------------- */ @@ -1122,7 +1122,7 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx) goto out; } /* nelmts */ - /* Free refrences */ + /* Free references */ if (is_new_ref) { if (H5Treclaim(tid, sid, H5P_DEFAULT, ndsbuf) < 0) goto out; @@ -1189,7 +1189,7 @@ out: dsbuf = NULL; } if (buf) { - /* Failure occured before H5Treclaim was called; + /* Failure occurred before H5Treclaim was called; free the pointers allocated when we read data in */ for (i = 0; i < rank; i++) { if (buf[i].p) @@ -1633,7 +1633,7 @@ H5DSiterate_scales(hid_t did, unsigned int dim, int *ds_idx, H5DS_iterate_t visi if (H5DSwith_new_ref(did, &is_new_ref) < 0) return FAIL; - /* get the number of scales assotiated with this DIM */ + /* get the number of scales associated with this DIM */ if ((nscales = H5DSget_num_scales(did, dim)) < 0) return FAIL; diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index e63ec92..e4b7090 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -1776,6 +1776,32 @@ H5LTset_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_nam } /*------------------------------------------------------------------------- + * Function: H5LTset_attribute_ullong + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Alessandro Felder + * + * Date: August 27, 2021 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTset_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name, + const unsigned long long *data, size_t size) +{ + + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_ULLONG, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- * Function: H5LTset_attribute_float * * Purpose: Create and write an attribute. @@ -1870,19 +1896,12 @@ H5LTfind_attribute(hid_t loc_id, const char *attr_name) * *------------------------------------------------------------------------- */ -/* H5Aiterate wants a non-const pointer but we have a const pointer in the API - * call. It's safe to ignore this because we control the callback, don't - * modify the op_data buffer (i.e.: attr_name) during the traversal, and the - * library never modifies that buffer. - */ -H5_GCC_DIAG_OFF("cast-qual") herr_t H5LT_find_attribute(hid_t loc_id, const char *attr_name) { htri_t attr_exists = H5Aexists(loc_id, attr_name); return (attr_exists < 0) ? (herr_t)-1 : (attr_exists) ? (herr_t)1 : (herr_t)0; } -H5_GCC_DIAG_ON("cast-qual") /*------------------------------------------------------------------------- * Function: H5LTget_attribute_ndims @@ -3272,6 +3291,33 @@ H5LTget_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_nam } /*------------------------------------------------------------------------- + * Function: H5LTget_attribute_ullong + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Alessandro Felder + * + * Date: August 27, 2021 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned long long *data) +{ + /* Get the attribute */ + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_ULLONG, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- * Function: H5LTget_attribute_float * * Purpose: Reads an attribute named attr_name diff --git a/hl/src/H5LTpublic.h b/hl/src/H5LTpublic.h index 47bb334..a6c7c84 100644 --- a/hl/src/H5LTpublic.h +++ b/hl/src/H5LTpublic.h @@ -139,6 +139,9 @@ H5_HLDLL herr_t H5LTset_attribute_long_long(hid_t loc_id, const char *obj_name, H5_HLDLL herr_t H5LTset_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned long *buffer, size_t size); +H5_HLDLL herr_t H5LTset_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name, + const unsigned long long *buffer, size_t size); + H5_HLDLL herr_t H5LTset_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, const float *buffer, size_t size); @@ -182,6 +185,9 @@ H5_HLDLL herr_t H5LTget_attribute_long_long(hid_t loc_id, const char *obj_name, H5_HLDLL herr_t H5LTget_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned long *data); +H5_HLDLL herr_t H5LTget_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name, + unsigned long long *data); + H5_HLDLL herr_t H5LTget_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, float *data); diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c index c66ef49..12b6840 100644 --- a/hl/test/test_ds.c +++ b/hl/test/test_ds.c @@ -3021,7 +3021,7 @@ test_simple(void) } /*------------------------------------------------------------------------- - * dettach for DIM0 + * detach for DIM0 *------------------------------------------------------------------------- */ @@ -3319,11 +3319,11 @@ test_simple(void) goto out; dim = 0; - /* iterate trough the 1st dimension of "dset_a" and verify that its DS is valid */ + /* iterate through the 1st dimension of "dset_a" and verify that its DS is valid */ if (H5DSiterate_scales(did, dim, NULL, verify_scale, NULL) < 0) goto out; - /* iterate trough the 2nd dimension of "dset_a" and verify that its DS is valid + /* iterate through the 2nd dimension of "dset_a" and verify that its DS is valid start at DS index 2 */ dim = 1; scale_idx = 2; @@ -3344,11 +3344,11 @@ test_simple(void) goto out; dim = 0; - /* iterate trough the 1st dimension of "dset_a" and read the DS */ + /* iterate through the 1st dimension of "dset_a" and read the DS */ if (H5DSiterate_scales(did, dim, NULL, read_scale, s1_wbuf) < 0) goto out; - /* iterate trough the 2nd dimension of "dset_a" and read the DS + /* iterate through the 2nd dimension of "dset_a" and read the DS start at DS index 2 */ dim = 1; scale_idx = 2; @@ -3381,9 +3381,9 @@ test_simple(void) goto out; { int match_size; /* does this scale size matches the dataset DIM size */ - int idx = 0; /* scale index to start iterating, on return, index where iterator stoped */ + int idx = 0; /* scale index to start iterating, on return, index where iterator stopped */ - /* iterate trough all the dimensions */ + /* iterate through all the dimensions */ for (dim = 0; dim < (unsigned)rank; dim++) { if ((match_size = H5DSiterate_scales(did, dim, &idx, match_dim_scale, NULL)) < 0) goto out; @@ -3475,9 +3475,9 @@ test_simple(void) goto out; { int match_size; /* does this scale size matches the dataset DIM size */ - int idx; /* scale index to start iterating, on return, index where iterator stoped */ + int idx; /* scale index to start iterating, on return, index where iterator stopped */ - /* iterate trough all the dimensions */ + /* iterate through all the dimensions */ for (dim = 0; dim < (unsigned)rank; dim++) { /* always start at 1st scale */ idx = 0; @@ -4025,7 +4025,7 @@ test_errors(void) PASSED(); /*------------------------------------------------------------------------- - * try to attach a scale to an image, pallete or table + * try to attach a scale to an image, palette or table *------------------------------------------------------------------------- */ @@ -4036,7 +4036,7 @@ test_errors(void) goto out; /* make a palette */ - if (H5IMmake_palette(fid, "pallete", pal_dims, NULL) < 0) + if (H5IMmake_palette(fid, "palette", pal_dims, NULL) < 0) goto out; /* open the previous written "ds_b" */ @@ -4248,7 +4248,7 @@ test_iterators(void) if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0) goto out; - /* try to iterate trough the 1st dimension of "dset_a", return error */ + /* try to iterate through the 1st dimension of "dset_a", return error */ if (H5DSiterate_scales(did, 0, NULL, verify_scale, NULL) < 0) goto out; @@ -4269,7 +4269,7 @@ test_iterators(void) if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0) goto out; - /* try to iterate trough the 3rd dimension of "dset_a", return error */ + /* try to iterate through the 3rd dimension of "dset_a", return error */ if (H5DSiterate_scales(did, 3, NULL, verify_scale, NULL) == SUCCEED) goto out; @@ -4306,7 +4306,7 @@ test_iterators(void) goto out; } - /* iterate trough the 1st dimension of "dset_a" */ + /* iterate through the 1st dimension of "dset_a" */ if (H5DSiterate_scales(did, 0, NULL, op_continue, NULL) < 0) goto out; diff --git a/hl/test/test_file_image.c b/hl/test/test_file_image.c index 36d4db3..4448e41 100644 --- a/hl/test/test_file_image.c +++ b/hl/test/test_file_image.c @@ -244,7 +244,7 @@ test_file_image(size_t open_images, size_t nflags, const unsigned *flags) */ HDmemset((uint8_t *)tmp_ptr + SUPER_STATUS_FLAGS_OFF_V0_V1, (int)0, (size_t)SUPER_STATUS_FLAGS_SIZE_V0_V1); - /* Does the comparision */ + /* Does the comparison */ if (HDmemcmp(tmp_ptr, buf_ptr[i], (size_t)buf_size[i]) != 0) FAIL_PUTS_ERROR("comparison of TMP vfd and user buffer failed"); /* Free the temporary buffer */ diff --git a/hl/test/test_h5do_compat.c b/hl/test/test_h5do_compat.c index c554ae7..6f19d4b 100644 --- a/hl/test/test_h5do_compat.c +++ b/hl/test/test_h5do_compat.c @@ -31,7 +31,7 @@ * * Purpose: Test the basic functionality of H5DOwrite_chunk * - * Return: Success: An identifer for the dataset used in the tests + * Return: Success: An identifier for the dataset used in the tests * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- diff --git a/hl/test/test_image.c b/hl/test/test_image.c index e54875e..4997df6 100644 --- a/hl/test/test_image.c +++ b/hl/test/test_image.c @@ -219,7 +219,7 @@ test_simple(void) *------------------------------------------------------------------------- */ - HL_TESTING2("pallete functions"); + HL_TESTING2("palette functions"); if (H5IMget_npalettes(fid, IMAGE1_NAME, &npals) < 0) goto out; @@ -422,7 +422,7 @@ test_data(void) /*------------------------------------------------------------------------- * palette #4. blue-red - * make a palette whith blue to red colors + * make a palette with blue to red colors *------------------------------------------------------------------------- */ for (i = 0, n = 0; i < 256 * 3; i += 3, n++) { diff --git a/hl/test/test_ld.c b/hl/test/test_ld.c index dc5755c..150d04c 100644 --- a/hl/test/test_ld.c +++ b/hl/test/test_ld.c @@ -189,7 +189,7 @@ typedef struct set_t { * This will fail on heiwa and amani when VALID_FIELDS1 is "field1,field3,field4" * because of alignment problems: * amani and heiwa - 8 byte alignment - * jam - 4 byte alignemnt + * jam - 4 byte alignment * This will need to be fixed in the library for H5Tget_native_type(). */ /* VALID_FIELDS1 "field1,field2.a,field3,field4" */ @@ -213,8 +213,8 @@ typedef struct test_valid_fields2 { #define TEST_BUF_SIZE 100 int * iibuf; /* buffer for storing retrieved elements */ int * ibuf; /* buffer for storing retrieved elements (integer) */ -set_t * cbuf; /* buffer for storing retrieved elemnets (compound) */ -set_t * ccbuf; /* buffer for storing retrieved elemnets (compound) */ +set_t * cbuf; /* buffer for storing retrieved elements (compound) */ +set_t * ccbuf; /* buffer for storing retrieved elements (compound) */ test_valid_fields1 *vbuf1; /* buffer for storing retrieved elements (FIELDS1) */ test_valid_fields2 *vbuf2; /* buffer for storing retrieved elements (FIELDS2) */ diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c index cae91ff..53f834a 100644 --- a/hl/test/test_lite.c +++ b/hl/test/test_lite.c @@ -43,8 +43,9 @@ #define ATTR7_NAME "attr ushort" #define ATTR8_NAME "attr uint" #define ATTR9_NAME "attr ulong" -#define ATTR10_NAME "attr float" -#define ATTR11_NAME "attr double" +#define ATTR10_NAME "attr ullong" +#define ATTR11_NAME "attr float" +#define ATTR12_NAME "attr double" static herr_t make_attributes(hid_t loc_id, const char *obj_name); @@ -472,28 +473,30 @@ make_attributes(hid_t loc_id, const char *obj_name) size_t type_size; int i; - char attr_str_in[] = {"My attribute"}; - char attr_str_out[20]; - char attr_char_in[5] = {1, 2, 3, 4, 5}; - char attr_char_out[5]; - short attr_short_in[5] = {1, 2, 3, 4, 5}; - short attr_short_out[5]; - int attr_int_in[5] = {1, 2, 3, 4, 5}; - int attr_int_out[5]; - long attr_long_in[5] = {1, 2, 3, 4, 5}; - long attr_long_out[5]; - float attr_float_in[5] = {1, 2, 3, 4, 5}; - float attr_float_out[5]; - double attr_double_in[5] = {1, 2, 3, 4, 5}; - double attr_double_out[5]; - unsigned char attr_uchar_in[5] = {1, 2, 3, 4, 5}; - unsigned char attr_uchar_out[5]; - unsigned short attr_ushort_in[5] = {1, 2, 3, 4, 5}; - unsigned short attr_ushort_out[5]; - unsigned int attr_uint_in[5] = {1, 2, 3, 4, 5}; - unsigned int attr_uint_out[5]; - unsigned long attr_ulong_in[5] = {1, 2, 3, 4, 5}; - unsigned long attr_ulong_out[5]; + char attr_str_in[] = {"My attribute"}; + char attr_str_out[20]; + char attr_char_in[5] = {1, 2, 3, 4, 5}; + char attr_char_out[5]; + short attr_short_in[5] = {1, 2, 3, 4, 5}; + short attr_short_out[5]; + int attr_int_in[5] = {1, 2, 3, 4, 5}; + int attr_int_out[5]; + long attr_long_in[5] = {1, 2, 3, 4, 5}; + long attr_long_out[5]; + float attr_float_in[5] = {1, 2, 3, 4, 5}; + float attr_float_out[5]; + double attr_double_in[5] = {1, 2, 3, 4, 5}; + double attr_double_out[5]; + unsigned char attr_uchar_in[5] = {1, 2, 3, 4, 5}; + unsigned char attr_uchar_out[5]; + unsigned short attr_ushort_in[5] = {1, 2, 3, 4, 5}; + unsigned short attr_ushort_out[5]; + unsigned int attr_uint_in[5] = {1, 2, 3, 4, 5}; + unsigned int attr_uint_out[5]; + unsigned long attr_ulong_in[5] = {1, 2, 3, 4, 5}; + unsigned long attr_ulong_out[5]; + unsigned long long attr_ullong_in[5] = {1, 2, 3, 4, 5}; + unsigned long long attr_ullong_out[5]; /*------------------------------------------------------------------------- * H5LTset_attribute_string test @@ -509,7 +512,7 @@ make_attributes(hid_t loc_id, const char *obj_name) PASSED(); /*------------------------------------------------------------------------- - * H5LTset_attribute_string test + * H5LTget_attribute_string test *------------------------------------------------------------------------- */ @@ -859,7 +862,7 @@ make_attributes(hid_t loc_id, const char *obj_name) PASSED(); /*------------------------------------------------------------------------- - * H5LTget_attribute_long test + * H5LTget_attribute_ulong test *------------------------------------------------------------------------- */ @@ -888,6 +891,48 @@ make_attributes(hid_t loc_id, const char *obj_name) PASSED(); /*------------------------------------------------------------------------- + * H5LTset_attribute_ullong test + *------------------------------------------------------------------------- + */ + + HL_TESTING2("H5LTset_attribute_ullong"); + + /* Set the attribute */ + if (H5LTset_attribute_ullong(loc_id, obj_name, ATTR10_NAME, attr_ullong_in, (size_t)5) < 0) + return -1; + + PASSED(); + + /*------------------------------------------------------------------------- + * H5LTget_attribute_ullong test + *------------------------------------------------------------------------- + */ + + HL_TESTING2("H5LTget_attribute_ullong"); + + /* Get the attribute */ + if (H5LTget_attribute_ullong(loc_id, obj_name, ATTR10_NAME, attr_ullong_out) < 0) + return -1; + + for (i = 0; i < 5; i++) { + if (attr_ullong_in[i] != attr_ullong_out[i]) { + return -1; + } + } + + /* Get the attribute */ + if (H5LTget_attribute(loc_id, obj_name, ATTR10_NAME, H5T_NATIVE_ULLONG, attr_ullong_out) < 0) + return -1; + + for (i = 0; i < 5; i++) { + if (attr_ullong_in[i] != attr_ullong_out[i]) { + return -1; + } + } + + PASSED(); + + /*------------------------------------------------------------------------- * H5LTset_attribute_float test *------------------------------------------------------------------------- */ @@ -895,7 +940,7 @@ make_attributes(hid_t loc_id, const char *obj_name) HL_TESTING2("H5LTset_attribute_float"); /* Set the attribute */ - if (H5LTset_attribute_float(loc_id, obj_name, ATTR10_NAME, attr_float_in, (size_t)5) < 0) + if (H5LTset_attribute_float(loc_id, obj_name, ATTR11_NAME, attr_float_in, (size_t)5) < 0) return -1; PASSED(); @@ -908,7 +953,7 @@ make_attributes(hid_t loc_id, const char *obj_name) HL_TESTING2("H5LTget_attribute_float"); /* Get the attribute */ - if (H5LTget_attribute_float(loc_id, obj_name, ATTR10_NAME, attr_float_out) < 0) + if (H5LTget_attribute_float(loc_id, obj_name, ATTR11_NAME, attr_float_out) < 0) return -1; for (i = 0; i < 5; i++) { @@ -918,7 +963,7 @@ make_attributes(hid_t loc_id, const char *obj_name) } /* Get the attribute */ - if (H5LTget_attribute(loc_id, obj_name, ATTR10_NAME, H5T_NATIVE_FLOAT, attr_float_out) < 0) + if (H5LTget_attribute(loc_id, obj_name, ATTR11_NAME, H5T_NATIVE_FLOAT, attr_float_out) < 0) return -1; for (i = 0; i < 5; i++) { @@ -937,7 +982,7 @@ make_attributes(hid_t loc_id, const char *obj_name) HL_TESTING2("H5LTset_attribute_double"); /* Set the attribute */ - if (H5LTset_attribute_double(loc_id, obj_name, ATTR11_NAME, attr_double_in, (size_t)5) < 0) + if (H5LTset_attribute_double(loc_id, obj_name, ATTR12_NAME, attr_double_in, (size_t)5) < 0) return -1; PASSED(); @@ -950,7 +995,7 @@ make_attributes(hid_t loc_id, const char *obj_name) HL_TESTING2("H5LTget_attribute_double"); /* Get the attribute */ - if (H5LTget_attribute_double(loc_id, obj_name, ATTR11_NAME, attr_double_out) < 0) + if (H5LTget_attribute_double(loc_id, obj_name, ATTR12_NAME, attr_double_out) < 0) return -1; for (i = 0; i < 5; i++) { @@ -960,7 +1005,7 @@ make_attributes(hid_t loc_id, const char *obj_name) } /* Get the attribute */ - if (H5LTget_attribute(loc_id, obj_name, ATTR11_NAME, H5T_NATIVE_DOUBLE, attr_double_out) < 0) + if (H5LTget_attribute(loc_id, obj_name, ATTR12_NAME, H5T_NATIVE_DOUBLE, attr_double_out) < 0) return -1; for (i = 0; i < 5; i++) { diff --git a/hl/test/test_packet_vlen.c b/hl/test/test_packet_vlen.c index c33479e..aa88a6c 100644 --- a/hl/test/test_packet_vlen.c +++ b/hl/test/test_packet_vlen.c @@ -677,7 +677,7 @@ error: /* An error has occurred. Clean up and exit. */ * * Description: * - Added a fixed-length packet table to the file for variety - * - Use the helper funtion verify_ptlengthtype to test H5PTis_varlen + * - Use the helper function verify_ptlengthtype to test H5PTis_varlen * on each packet table. * * 2016/01/27 -BMR diff --git a/hl/test/test_table.c b/hl/test/test_table.c index 6199e27..90a930c 100644 --- a/hl/test/test_table.c +++ b/hl/test/test_table.c @@ -1464,7 +1464,7 @@ test_table(hid_t fid, int do_write) HL_TESTING2("getting field info"); - /* alocate */ + /* allocate */ names_out = (char **)HDmalloc(sizeof(char *) * (size_t)NFIELDS); for (i = 0; i < NFIELDS; i++) { names_out[i] = (char *)HDmalloc(sizeof(char) * 255); diff --git a/hl/tools/gif2h5/decompress.c b/hl/tools/gif2h5/decompress.c index 64d9643..ca33f86 100644 --- a/hl/tools/gif2h5/decompress.c +++ b/hl/tools/gif2h5/decompress.c @@ -178,7 +178,7 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) DataMask = (1 << ((GifHead->PackedField & 0x07) + 1)) - 1; Raster = GifImageDesc->GIFImage; - /* Check for image seperator */ + /* Check for image separator */ /* Now read in values from the image descriptor */ IWidth = GifImageDesc->ImageWidth; @@ -193,7 +193,7 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) */ /* - * Start reading the raster data. First we get the intial code size and + * Start reading the raster data. First we get the initial code size and * compute decompressor constant values, based on this code size. */ diff --git a/hl/tools/gif2h5/gif2mem.c b/hl/tools/gif2h5/gif2mem.c index c66250b..44e18e0 100644 --- a/hl/tools/gif2h5/gif2mem.c +++ b/hl/tools/gif2h5/gif2mem.c @@ -40,7 +40,7 @@ Gif2Mem(GIFBYTE *MemGif, GIFTOMEM *GifMemoryStruct) { /* * The gif structure outline for passing data to memory is given in gif.h. - * These pointers are redunant, should take them out in ver. 2 + * These pointers are redundant, should take them out in ver. 2 */ GIFHEAD * gifHead; /* GIF Header structure */ GIFIMAGEDESC ** gifImageDesc; /* Logical Image Descriptor struct */ @@ -49,22 +49,22 @@ Gif2Mem(GIFBYTE *MemGif, GIFTOMEM *GifMemoryStruct) GIFCOMMENT ** gifComment; /* Comment Extension structure */ GIFGRAPHICCONTROL **gifGraphicControl; /* Graphic Control Extension strct */ - register GIFWORD i; /* Loop counter */ - GIFBYTE Identifier; /* Extension block identifier holder */ - GIFBYTE Label; /* Extension block label holder */ - GIFBYTE ImageCount; /* Count of the number of images in the file */ - GIFBYTE ImageArray; /* Keep the size of the array to store Images */ - GIFBYTE CommentCount; - GIFBYTE CommentArray; - GIFBYTE ApplicationCount; - GIFBYTE ApplicationArray; - GIFBYTE PlainTextCount; - GIFBYTE PlainTextArray; - GIFBYTE GCEflag; - GIFBYTE aTemp; - GIFBYTE j; - GIFBYTE w; /* Two more variables needed only while testing */ - GIFBYTE * b; /* Endian Ordering */ + GIFWORD i; /* Loop counter */ + GIFBYTE Identifier; /* Extension block identifier holder */ + GIFBYTE Label; /* Extension block label holder */ + GIFBYTE ImageCount; /* Count of the number of images in the file */ + GIFBYTE ImageArray; /* Keep the size of the array to store Images */ + GIFBYTE CommentCount; + GIFBYTE CommentArray; + GIFBYTE ApplicationCount; + GIFBYTE ApplicationArray; + GIFBYTE PlainTextCount; + GIFBYTE PlainTextArray; + GIFBYTE GCEflag; + GIFBYTE aTemp; + GIFBYTE j; + GIFBYTE w; /* Two more variables needed only while testing */ + GIFBYTE *b; /* Endian Ordering */ /* Allocate memory for the GIF structures */ /* Plug the structs into GifMemoryStruct at the end */ diff --git a/hl/tools/gif2h5/gifread.c b/hl/tools/gif2h5/gifread.c index dd9e5be..3a6bcae 100644 --- a/hl/tools/gif2h5/gifread.c +++ b/hl/tools/gif2h5/gifread.c @@ -50,15 +50,15 @@ GetByte(const GIFBYTE *MemGif) * Global Color Table (if any) from a GIF image file. The information * is stored in a GIFHEAD structure. * - * Returns: -1 if a FILE stream error occured during the read, - * otherwise 0 if no error occured. + * Returns: -1 if a FILE stream error occurred during the read, + * otherwise 0 if no error occurred. */ int ReadGifHeader(GIFHEAD * GifHead, /* Pointer to GIF header structure */ GIFBYTE **MemGif2) /* GIF image file input FILE stream */ { GIFWORD i; /* Loop counter */ - GIFWORD tableSize; /* Number of entires in the Global Color Table */ + GIFWORD tableSize; /* Number of entries in the Global Color Table */ GifHead->TableSize = 0; for (i = 0; i < 6; i++) { @@ -103,7 +103,7 @@ ReadGifHeader(GIFHEAD * GifHead, /* Pointer to GIF header structure */ return -1; #endif /* 0 */ - return 0; /* No FILE stream error occured */ + return 0; /* No FILE stream error occurred */ } /* @@ -116,8 +116,8 @@ ReadGifHeader(GIFHEAD * GifHead, /* Pointer to GIF header structure */ ** Note that the ImageSeparator field value in the GIFIMAGEDESC ** structure is assigned by the function calling ReadGifImageDesc(). ** -** Returns: -1 if a FILE stream error occured during the read, -** otherwise 0 if no error occured. +** Returns: -1 if a FILE stream error occurred during the read, +** otherwise 0 if no error occurred. */ int ReadGifImageDesc(GIFIMAGEDESC *GifImageDesc, /* Pointer to GIF image descriptor structure */ @@ -196,7 +196,7 @@ ReadGifImageDesc(GIFIMAGEDESC *GifImageDesc, /* Pointer to GIF image descriptor *TempPtr++ = *(*MemGif2)++; } while (ch1); - return (0); /* No FILE stream error occured */ + return (0); /* No FILE stream error occurred */ } /* @@ -205,8 +205,8 @@ ReadGifImageDesc(GIFIMAGEDESC *GifImageDesc, /* Pointer to GIF image descriptor ** Note that the Introducer and Label field values in the GIFGRAPHICCONTROL ** structure are assigned by the function calling ReadGifGraphicControl(). ** -** Returns: -1 if a FILE stream error occured during the read, -** otherwise 0 if no error occured. +** Returns: -1 if a FILE stream error occurred during the read, +** otherwise 0 if no error occurred. */ int ReadGifGraphicControl(GIFGRAPHICCONTROL *GifGraphicControl, /* Pointer to GC Extension structure */ @@ -219,7 +219,7 @@ ReadGifGraphicControl(GIFGRAPHICCONTROL *GifGraphicControl, /* Pointer to GC Ext GifGraphicControl->GCEDump[i] = *(*MemGif2)++; } - return (0); /* No FILE stream error occured */ + return (0); /* No FILE stream error occurred */ } /* @@ -228,8 +228,8 @@ ReadGifGraphicControl(GIFGRAPHICCONTROL *GifGraphicControl, /* Pointer to GC Ext ** Note that the Introducer and Label field values in the GIFLPLAINTEXT ** structure are assigned by the function calling ReadGifPlainText(). ** -** Returns: -1 if a FILE stream error occured during the read, -** otherwise 0 if no error occured. +** Returns: -1 if a FILE stream error occurred during the read, +** otherwise 0 if no error occurred. */ int ReadGifPlainText(GIFPLAINTEXT *GifPlainText, /* Pointer to Plain Text Extension structure */ @@ -256,7 +256,7 @@ ReadGifPlainText(GIFPLAINTEXT *GifPlainText, /* Pointer to Plain Text Extension return(-1); */ - return (0); /* No FILE stream error occured */ + return (0); /* No FILE stream error occurred */ } /* @@ -265,8 +265,8 @@ ReadGifPlainText(GIFPLAINTEXT *GifPlainText, /* Pointer to Plain Text Extension ** Note that the Introducer and Label field values in the GIFAPPLICATION ** structure are assigned by the function calling ReadGifApplication(). ** -** Returns: -1 if a FILE stream error occured during the read, -** otherwise 0 if no error occured. +** Returns: -1 if a FILE stream error occurred during the read, +** otherwise 0 if no error occurred. */ int ReadGifApplication(GIFAPPLICATION *GifApplication, /* Pointer to Application Extension structure */ @@ -292,7 +292,7 @@ ReadGifApplication(GIFAPPLICATION *GifApplication, /* Pointer to Application Ext return(-1); */ - return (0); /* No FILE stream error occured */ + return (0); /* No FILE stream error occurred */ } /* @@ -301,8 +301,8 @@ ReadGifApplication(GIFAPPLICATION *GifApplication, /* Pointer to Application Ext ** Note that the Introducer and Label field values in the GIFCOMMENT ** structure are assigned by the function calling ReadGifComment(). ** -** Returns: -1 if a FILE stream error occured during the read, -** otherwise 0 if no error occured. +** Returns: -1 if a FILE stream error occurred during the read, +** otherwise 0 if no error occurred. */ int ReadGifComment(GIFCOMMENT *GifComment, /* Pointer to GIF Comment Extension structure */ @@ -316,7 +316,7 @@ ReadGifComment(GIFCOMMENT *GifComment, /* Pointer to GIF Comment Extension struc GifComment->Terminator = 0; - return (0); /* No FILE stream error occured */ + return (0); /* No FILE stream error occurred */ } /* @@ -326,8 +326,8 @@ ReadGifComment(GIFCOMMENT *GifComment, /* Pointer to GIF Comment Extension struc ** A GIF "sub-block" is a single count byte followed by 1 to 255 ** additional data bytes. ** -** Returns: A NULL pointer if a memory allocation error occured, -** otherwise a valid pointer if no error occured. +** Returns: A NULL pointer if a memory allocation error occurred, +** otherwise a valid pointer if no error occurred. */ static GIFBYTE * ReadDataSubBlocks(GIFBYTE **MemGif2, /* GIF image file input FILE stream */ @@ -364,7 +364,7 @@ ReadDataSubBlocks(GIFBYTE **MemGif2, /* GIF image file input FILE stream if ((dataSize = *(*MemGif2)++) == 0) break; /* Block Terminator encountered */ - /* Increase the buffer size to accomodate the next sub-block */ + /* Increase the buffer size to accommodate the next sub-block */ if (!(ptr1 = ptr2 = (GIFBYTE *)realloc(ptr2, bufSize + dataSize + 1))) return ((GIFBYTE *)NULL); diff --git a/hl/tools/gif2h5/h52giftest.sh.in b/hl/tools/gif2h5/h52giftest.sh.in index 2f84ef6..4f4057f 100644 --- a/hl/tools/gif2h5/h52giftest.sh.in +++ b/hl/tools/gif2h5/h52giftest.sh.in @@ -46,7 +46,7 @@ TOOLTEST() # Verify the test runs with failure (return code is not 0) # Use for testing if tool can handle error conditions like -# illegal input, bad arguments, exeeding limits, ... +# illegal input, bad arguments, exceeding limits, ... TOOLTESTFAIL() { # for now, discard any error messages generated. diff --git a/hl/tools/gif2h5/hdfgifwr.c b/hl/tools/gif2h5/hdfgifwr.c index 21b14d1..7126da9 100644 --- a/hl/tools/gif2h5/hdfgifwr.c +++ b/hl/tools/gif2h5/hdfgifwr.c @@ -188,13 +188,13 @@ hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, const byte *rmap, cons static void compress(int init_bits, FILE *outfile, byte *data, int len) { - register long fcode; - register int i = 0; - register int c; - register int ent; - register int disp; - register int hsize_reg; - register int hshift; + long fcode; + int i = 0; + int c; + int ent; + int disp; + int hsize_reg; + int hshift; /* * Set up the globals: g_init_bits - initial number of bits g_outfile - diff --git a/hl/tools/gif2h5/writehdf.c b/hl/tools/gif2h5/writehdf.c index a444cf7..b49e2a6 100644 --- a/hl/tools/gif2h5/writehdf.c +++ b/hl/tools/gif2h5/writehdf.c @@ -27,7 +27,7 @@ * Programmer: Unknown * * Modifications: pvn - * Use the HDF5 IMAGE API to write the HDF5 image and pallete + * Use the HDF5 IMAGE API to write the HDF5 image and palette * * Date: January, 31, 2006 * @@ -68,7 +68,7 @@ WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName) #endif /* UNUSED */ if ((file_id = H5Fcreate(HDFName, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { - /* error occured opening the HDF File for write */ + /* error occurred opening the HDF File for write */ fprintf(stderr, "HDF file could not be opened for writing\n"); fprintf(stderr, "NOTE: GIF file must be present in the same directory as the binary on UNIX systems.\n"); diff --git a/hl/tools/h5watch/extend_dset.c b/hl/tools/h5watch/extend_dset.c index 07a4053..7756506 100644 --- a/hl/tools/h5watch/extend_dset.c +++ b/hl/tools/h5watch/extend_dset.c @@ -83,7 +83,7 @@ extend_dset_two(const char *file, char *dname, int action1, int action2) size_t dtype_size; /* size of the dataset's datatype */ unsigned num_elmts; /* number of elements in the dataset */ int * ibuf = NULL; /* buffer for storing retrieved elements (integer) */ - set_t * cbuf = NULL; /* buffer for storing retrieved elemnets (compound) */ + set_t * cbuf = NULL; /* buffer for storing retrieved elements (compound) */ /* Allocate memory */ if (NULL == (ibuf = (int *)HDcalloc(TEST_BUF_SIZE, sizeof(int)))) @@ -237,7 +237,7 @@ extend_dset_one(const char *file, char *dname, int action) hsize_t count[1]; /* dimension sizes of appended data */ size_t dtype_size; /* size of the dataset's datatype */ int * ibuf = NULL; /* buffer for storing retrieved elements (integer) */ - set_t * cbuf = NULL; /* buffer for storing retrieved elemnets (compound) */ + set_t * cbuf = NULL; /* buffer for storing retrieved elements (compound) */ /* Allocate memory */ if (NULL == (ibuf = (int *)HDcalloc(TEST_BUF_SIZE, sizeof(int)))) -- cgit v0.12 From 8da35c7bdf5059f3c8a2b0a64d5a0d815a7d7d46 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Thu, 7 Apr 2022 06:14:04 -0700 Subject: Normalization of Java with develop (#1607) --- java/src/hdf/hdf5lib/HDF5Constants.java | 14 +++++++------- java/src/hdf/hdf5lib/exceptions/HDF5LibraryException.java | 4 ++-- java/src/jni/h5util.c | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/java/src/hdf/hdf5lib/HDF5Constants.java b/java/src/hdf/hdf5lib/HDF5Constants.java index dea49dd..0a99fa4 100644 --- a/java/src/hdf/hdf5lib/HDF5Constants.java +++ b/java/src/hdf/hdf5lib/HDF5Constants.java @@ -158,15 +158,15 @@ public class HDF5Constants { public static final long H5E_ALREADYINIT = H5E_ALREADYINIT(); /** Major error codes - Invalid arguments to routine */ public static final long H5E_ARGS = H5E_ARGS(); - /** Major error codes - Object atom */ + /** Major error codes - Object ID */ public static final long H5E_ATOM = H5E_ATOM(); /** Major error codes - Attribute */ public static final long H5E_ATTR = H5E_ATTR(); - /** Minor error codes - Object atom related errors - Unable to find atom information (already closed?) */ + /** Minor error codes - Object ID related errors - Unable to find ID information (already closed?) */ public static final long H5E_BADATOM = H5E_BADATOM(); /** Minor error codes - File accessibility errors - Bad file ID accessed */ public static final long H5E_BADFILE = H5E_BADFILE(); - /** Minor error codes - Object atom related errors - Unable to find ID group information */ + /** Minor error codes - Object ID related errors - Unable to find ID group information */ public static final long H5E_BADGROUP = H5E_BADGROUP(); /** Minor error codes - Object header related errors - Iteration failed */ public static final long H5E_BADITER = H5E_BADITER(); @@ -218,7 +218,7 @@ public class HDF5Constants { public static final long H5E_CANTCOUNT = H5E_CANTCOUNT(); /** Minor error codes - File accessibility errors - Unable to create file */ public static final long H5E_CANTCREATE = H5E_CANTCREATE(); - /** Minor error codes - Object atom related errors - Unable to decrement reference count */ + /** Minor error codes - Object ID related errors - Unable to decrement reference count */ public static final long H5E_CANTDEC = H5E_CANTDEC(); /** Minor error codes - B-tree related errors - Unable to decode value */ public static final long H5E_CANTDECODE = H5E_CANTDECODE(); @@ -250,7 +250,7 @@ public class HDF5Constants { public static final long H5E_CANTGET = H5E_CANTGET(); /** Minor error codes - Resource errors - Unable to compute size */ public static final long H5E_CANTGETSIZE = H5E_CANTGETSIZE(); - /** Minor error codes - Object atom related errors - Unable to increment reference count */ + /** Minor error codes - Object ID related errors - Unable to increment reference count */ public static final long H5E_CANTINC = H5E_CANTINC(); /** Minor error codes - Function entry/exit interface - Unable to initialize object */ public static final long H5E_CANTINIT = H5E_CANTINIT(); @@ -300,7 +300,7 @@ public class HDF5Constants { public static final long H5E_CANTRECV = H5E_CANTRECV(); /** Minor error codes - B-tree related errors - Unable to redistribute records */ public static final long H5E_CANTREDISTRIBUTE = H5E_CANTREDISTRIBUTE(); - /** Minor error codes - Object atom related errors - Unable to register new atom */ + /** Minor error codes - Object ID related errors - Unable to register new ID */ public static final long H5E_CANTREGISTER = H5E_CANTREGISTER(); /** Minor error codes - Function entry/exit interface - Unable to release object */ public static final long H5E_CANTRELEASE = H5E_CANTRELEASE(); @@ -416,7 +416,7 @@ public class HDF5Constants { public static final long H5E_NOENCODER = H5E_NOENCODER(); /** I/O pipeline errors - Requested filter is not available */ public static final long H5E_NOFILTER = H5E_NOFILTER(); - /** Minor error codes - Object atom related errors - Out of IDs for group */ + /** Minor error codes - Object ID related errors - Out of IDs for group */ public static final long H5E_NOIDS = H5E_NOIDS(); /** Major error codes - No error */ public static final long H5E_NONE_MAJOR = H5E_NONE_MAJOR(); diff --git a/java/src/hdf/hdf5lib/exceptions/HDF5LibraryException.java b/java/src/hdf/hdf5lib/exceptions/HDF5LibraryException.java index 71ba795..62a8047 100644 --- a/java/src/hdf/hdf5lib/exceptions/HDF5LibraryException.java +++ b/java/src/hdf/hdf5lib/exceptions/HDF5LibraryException.java @@ -204,13 +204,13 @@ public class HDF5LibraryException extends HDF5Exception { return "Can't release object"; } else if (err_code == HDF5Constants.H5E_BADATOM) { - return "Can't find atom information"; + return "Can't find ID information"; } else if (err_code == HDF5Constants.H5E_BADGROUP) { return "Can't find group information"; } else if (err_code == HDF5Constants.H5E_CANTREGISTER) { - return "Can't register new atom"; + return "Can't register new ID"; } else if (err_code == HDF5Constants.H5E_CANTINC) { return "Can't increment reference count"; diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index 5a01dc9..2de5d87 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -813,7 +813,7 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsnprintf(this_str, "%g", this_len, tmp_double) < 0) + if (HDsnprintf(this_str, this_len, "%g", tmp_double) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); break; @@ -1160,11 +1160,11 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i H5Otoken_to_str(tid, &oi.token, &token_str); - size_t this_len = 64 + strlen(token_str) + 1; - if (NULL == (this_str = (char *)HDmalloc(this_len))) + size_t that_len = 64 + strlen(token_str) + 1; + if (NULL == (this_str = HDmalloc(that_len))) H5_OUT_OF_MEMORY_ERROR( ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsnprintf(this_str, this_len, "%lu:%s", oi.fileno, token_str) < + if (HDsnprintf(this_str, that_len, "%lu:%s", oi.fileno, token_str) < 0) H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); -- cgit v0.12 From 541bc15452f71f3eae7471fdecbe7994a7f138e2 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Thu, 7 Apr 2022 06:16:24 -0700 Subject: Normalize Fortran code with develop (#1600) --- fortran/examples/compound.f90 | 14 ++++++------- fortran/examples/h5_cmprss.f90 | 2 +- fortran/examples/h5_crtatt.f90 | 2 +- fortran/examples/h5_extend.f90 | 4 ++-- fortran/examples/refobjexample.f90 | 2 +- fortran/examples/testh5fc.sh.in | 2 +- fortran/src/H5Af.c | 8 ++++---- fortran/src/H5Aff.F90 | 14 ++++++------- fortran/src/H5Df.c | 14 ++++++------- fortran/src/H5Dff.F90 | 18 +++++++---------- fortran/src/H5Ff.c | 4 ++-- fortran/src/H5Fff.F90 | 2 +- fortran/src/H5Gf.c | 8 ++++---- fortran/src/H5Gff.F90 | 32 ++++++++++++++--------------- fortran/src/H5Lff.F90 | 6 +++--- fortran/src/H5Pf.c | 30 ++++++++++++++-------------- fortran/src/H5Pff.F90 | 16 +++++++-------- fortran/src/H5Sf.c | 8 ++++---- fortran/src/H5Sff.F90 | 2 +- fortran/src/H5Tf.c | 6 +++--- fortran/src/H5Tff.F90 | 4 ++-- fortran/src/H5_buildiface.F90 | 8 ++++---- fortran/src/H5_ff.F90 | 4 ++-- fortran/src/H5f90global.F90 | 4 ++-- fortran/src/H5f90proto.h | 2 +- fortran/src/h5fc.in | 6 +++--- fortran/test/H5_test_buildiface.F90 | 2 +- fortran/test/fflush1.F90 | 2 +- fortran/test/fflush2.F90 | 4 ++-- fortran/test/tH5A.F90 | 2 +- fortran/test/tH5A_1_8.F90 | 23 +++++++++------------ fortran/test/tH5D.F90 | 16 +++++++-------- fortran/test/tH5F.F90 | 40 +++++++++++++++++++++++++++++++++---- fortran/test/tH5G_1_8.F90 | 2 +- fortran/test/tH5MISC_1_8.F90 | 2 +- fortran/test/tH5P.F90 | 10 +++++----- fortran/test/tH5R.F90 | 2 +- fortran/test/tH5S.F90 | 16 +++++++-------- fortran/test/tH5Sselect.F90 | 12 +++++------ fortran/test/tH5T.F90 | 18 ++++++++--------- fortran/test/tH5VL.F90 | 4 ++-- fortran/test/tH5Z.F90 | 2 +- hl/fortran/src/H5DSff.F90 | 2 +- hl/fortran/src/H5HL_buildiface.F90 | 2 +- hl/fortran/src/H5LTff.F90 | 4 ++-- hl/fortran/src/H5TBfc.c | 4 ++-- hl/fortran/src/H5TBff.F90 | 2 +- hl/fortran/test/tsttable.F90 | 8 ++++---- 48 files changed, 212 insertions(+), 189 deletions(-) diff --git a/fortran/examples/compound.f90 b/fortran/examples/compound.f90 index d9f8235..57624c6 100644 --- a/fortran/examples/compound.f90 +++ b/fortran/examples/compound.f90 @@ -41,7 +41,7 @@ INTEGER(HID_T) :: dt3_id ! Memory datatype identifier (for double precision field) INTEGER(HID_T) :: dt4_id ! Memory datatype identifier (for real field) INTEGER(HID_T) :: dt5_id ! Memory datatype identifier - INTEGER(HID_T) :: plist_id ! Dataset trasfer property + INTEGER(HID_T) :: plist_id ! Dataset transfer property INTEGER(SIZE_T) :: typesize @@ -111,21 +111,21 @@ type_size = type_sizec + type_sizei + type_sized + type_sizer CALL h5tcreate_f(H5T_COMPOUND_F, type_size, dtype_id, error) ! - ! Insert memebers + ! Insert members ! - ! CHARACTER*2 memeber + ! CHARACTER*2 member ! offset = 0 CALL h5tinsert_f(dtype_id, "char_field", offset, dt5_id, error) ! ! INTEGER member ! - offset = offset + type_sizec ! Offset of the second memeber is 2 + offset = offset + type_sizec ! Offset of the second member is 2 CALL h5tinsert_f(dtype_id, "integer_field", offset, H5T_NATIVE_INTEGER, error) ! ! DOUBLE PRECISION member ! - offset = offset + type_sizei ! Offset of the third memeber is 6 + offset = offset + type_sizei ! Offset of the third member is 6 CALL h5tinsert_f(dtype_id, "double_field", offset, H5T_NATIVE_DOUBLE, error) ! ! REAL member @@ -198,7 +198,7 @@ ! CALL h5dopen_f(file_id, dsetname, dset_id, error) ! - ! Create memeory datatyoe to read character member of the compound datatype. + ! Create memory datatype to read character member of the compound datatype. ! CALL h5tcopy_f(H5T_NATIVE_CHARACTER, dt2_id, error) typesize = 2 @@ -208,7 +208,7 @@ offset = 0 CALL h5tinsert_f(dt1_id, "char_field", offset, dt2_id, error) ! - ! Read part of the datatset and display it. + ! Read part of the dataset and display it. ! CALL h5dread_f(dset_id, dt1_id, char_member_out, data_dims, error) write(*,*) (char_member_out(i), i=1, dimsize) diff --git a/fortran/examples/h5_cmprss.f90 b/fortran/examples/h5_cmprss.f90 index 61efc30..86d9cfa 100644 --- a/fortran/examples/h5_cmprss.f90 +++ b/fortran/examples/h5_cmprss.f90 @@ -51,7 +51,7 @@ PROGRAM h5_cmprss !INTEGER :: szip_pixels_per_block ! - !Initialize FORTRAN predifined datatypes + !Initialize FORTRAN predefined datatypes ! CALL h5open_f(error) ! diff --git a/fortran/examples/h5_crtatt.f90 b/fortran/examples/h5_crtatt.f90 index 996a506..64d2bde 100644 --- a/fortran/examples/h5_crtatt.f90 +++ b/fortran/examples/h5_crtatt.f90 @@ -35,7 +35,7 @@ PROGRAM H5_CRTATT INTEGER(HID_T) :: aspace_id ! Attribute Dataspace identifier INTEGER(HID_T) :: atype_id ! Attribute Dataspace identifier INTEGER(HSIZE_T), DIMENSION(1) :: adims = (/2/) ! Attribute dimension - INTEGER :: arank = 1 ! Attribure rank + INTEGER :: arank = 1 ! Attribute rank INTEGER(SIZE_T) :: attrlen ! Length of the attribute string CHARACTER(LEN=80), DIMENSION(2) :: attr_data ! Attribute data diff --git a/fortran/examples/h5_extend.f90 b/fortran/examples/h5_extend.f90 index 0ad6ef9..193f33e 100644 --- a/fortran/examples/h5_extend.f90 +++ b/fortran/examples/h5_extend.f90 @@ -86,7 +86,7 @@ PROGRAM H5_EXTEND INTEGER, DIMENSION(1:3,1:10) :: rdata ! - !Initialize FORTRAN predifined datatypes + !Initialize FORTRAN predefined datatypes ! CALL h5open_f(error) @@ -110,7 +110,7 @@ PROGRAM H5_EXTEND CALL h5pset_chunk_f(crp_list, RANK, dimsc, error) ! - !Create a dataset with 3X3 dimensions using cparms creation propertie . + !Create a dataset with 3X3 dimensions using cparms creation properties . ! CALL h5dcreate_f(file_id, dsetname, H5T_NATIVE_INTEGER, dataspace, & dset_id, error, crp_list ) diff --git a/fortran/examples/refobjexample.f90 b/fortran/examples/refobjexample.f90 index d420192..873b420 100644 --- a/fortran/examples/refobjexample.f90 +++ b/fortran/examples/refobjexample.f90 @@ -26,7 +26,7 @@ IMPLICIT NONE CHARACTER(LEN=10), PARAMETER :: filename = "FORTRAN.h5" ! File CHARACTER(LEN=8), PARAMETER :: dsetnamei = "INTEGERS" ! Dataset with the integer data - CHARACTER(LEN=17), PARAMETER :: dsetnamer = "OBJECT_REFERENCES" ! Dataset wtih object + CHARACTER(LEN=17), PARAMETER :: dsetnamer = "OBJECT_REFERENCES" ! Dataset with object ! references CHARACTER(LEN=6), PARAMETER :: groupname1 = "GROUP1" ! Groups in the file CHARACTER(LEN=6), PARAMETER :: groupname2 = "GROUP2" ! diff --git a/fortran/examples/testh5fc.sh.in b/fortran/examples/testh5fc.sh.in index db687d8..71f41f8 100644 --- a/fortran/examples/testh5fc.sh.in +++ b/fortran/examples/testh5fc.sh.in @@ -61,7 +61,7 @@ applib=libapp${H5TOOL}.a # short hands # Caution: if some *.h5 files must be cleaned here, list them by names. # Don't use the wildcard form of *.h5 as it will wipe out even *.h5 generated -# by otehr test programs. This will cause a racing condition error when +# by other test programs. This will cause a racing condition error when # parallel make (e.g., gmake -j 4) is used. temp_SRC="$hdf5main $appmain $prog1 $prog2" temp_OBJ=`echo $temp_SRC | sed -e "s/\.${suffix}/.o/g"` diff --git a/fortran/src/H5Af.c b/fortran/src/H5Af.c index f78ade2..db1c040 100644 --- a/fortran/src/H5Af.c +++ b/fortran/src/H5Af.c @@ -272,7 +272,7 @@ done: * PURPOSE * Call H5Aopen to open an attribute * INPUTS - * obj_id - Identifer for object to which attribute is attached + * obj_id - Identifier for object to which attribute is attached * attr_name - Attribute access property list * attr_namelen - size of attr_name * aapl_id - Link access property list @@ -317,7 +317,7 @@ done: * PURPOSE * Call h5adelete_by_name to remove an attribute from a specified location * INPUTS - * loc_id - identifer for object to which attribute is attached + * loc_id - identifier for object to which attribute is attached * obj_name - object identifier * obj_namelen - name length * attr_name - name of the attribute @@ -424,7 +424,7 @@ done: * INPUTS * * - * loc_id - Identifer for object to which attribute is attached + * loc_id - Identifier for object to which attribute is attached * obj_name - Name of object, relative to location, * from which attribute is to be removed *TEST* check NULL * idx_type - Type of index; Possible values are: @@ -532,7 +532,7 @@ done: * aapl_id - Attribute access property list * lapl_id - Link access property list * OUTPUTS - * attr_id - attribute identifer + * attr_id - attribute identifier * RETURNS * 0 on success, -1 on failure * AUTHOR diff --git a/fortran/src/H5Aff.F90 b/fortran/src/H5Aff.F90 index 8f56993..53f0a39 100644 --- a/fortran/src/H5Aff.F90 +++ b/fortran/src/H5Aff.F90 @@ -211,7 +211,7 @@ CONTAINS ! ! INPUTS ! obj_id - identifier of a group, dataset, or named -! datatype atttribute to be attached to +! datatype attribute to be attached to ! name - attribute name ! OUTPUTS ! attr_id - attribute identifier @@ -487,7 +487,7 @@ CONTAINS SUBROUTINE h5aget_name_by_idx_f(loc_id, obj_name, idx_type, order, & n, name, hdferr, size, lapl_id) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: loc_id ! Identifer for object to which attribute is attached + INTEGER(HID_T), INTENT(IN) :: loc_id ! Identifier for object to which attribute is attached CHARACTER(LEN=*), INTENT(IN) :: obj_name ! Name of object, relative to location, ! from which attribute is to be removed *TEST* check NULL INTEGER, INTENT(IN) :: idx_type ! Type of index; Possible values are: @@ -846,7 +846,7 @@ CONTAINS ! identifier and attribute name ! ! INPUTS -! obj_id - Identifer for object to which attribute is attached +! obj_id - Identifier for object to which attribute is attached ! attr_name - Name of attribute to open ! OUTPUTS ! attr_id - attribute identifier @@ -934,7 +934,7 @@ CONTAINS ! SOURCE SUBROUTINE H5Adelete_by_idx_f(loc_id, obj_name, idx_type, order, n, hdferr, lapl_id) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: loc_id ! Identifer for object to which attribute is attached + INTEGER(HID_T), INTENT(IN) :: loc_id ! Identifier for object to which attribute is attached CHARACTER(LEN=*), INTENT(IN) :: obj_name ! Name of object, relative to location, ! from which attribute is to be removed INTEGER, INTENT(IN) :: idx_type ! Type of index; Possible values are: @@ -991,7 +991,7 @@ CONTAINS ! Removes an attribute from a specified location ! ! INPUTS -! loc_id - Identifer for object to which attribute is attached +! loc_id - Identifier for object to which attribute is attached ! obj_name - Name of attribute to open ! attr_name - Attribute access property list ! lapl_id - Link access property list @@ -1005,7 +1005,7 @@ CONTAINS ! SOURCE SUBROUTINE H5Adelete_by_name_f(loc_id, obj_name, attr_name, hdferr, lapl_id) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: loc_id ! Identifer for object to which attribute is attached + INTEGER(HID_T), INTENT(IN) :: loc_id ! Identifier for object to which attribute is attached CHARACTER(LEN=*), INTENT(IN) :: obj_name ! Name of object, relative to location, ! from which attribute is to be removed CHARACTER(LEN=*), INTENT(IN) :: attr_name ! Name of attribute to delete @@ -1841,7 +1841,7 @@ CONTAINS ! dims parameter was added to make code portable; ! Aprile 4, 2001 ! -! Changed buf intent to INOUT to be consistant +! Changed buf intent to INOUT to be consistent ! with how the C functions handles it. The pg ! compiler will return 0 if a buf value is not set. ! February, 2008 diff --git a/fortran/src/H5Df.c b/fortran/src/H5Df.c index bcf792c..a780683 100644 --- a/fortran/src/H5Df.c +++ b/fortran/src/H5Df.c @@ -145,7 +145,7 @@ DONE: * Elena Pourmal * Tuesday, May 14, 2002 * HISTORY - * This function was added to accomodate h5dwrite_f with the + * This function was added to accommodate h5dwrite_f with the * dims argument being of INTEGER(HSIZE_T) type * SOURCE */ @@ -217,7 +217,7 @@ h5dwrite_ref_reg_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id * Elena Pourmal * Wednesday, May 15, 2002 * HISTORY - * This function was added to accomodate h5dread_f subroutine + * This function was added to accommodate h5dread_f subroutine * with the dims parameter being of INTEGER(HSIZE_T_F) size. * SOURCE */ @@ -495,10 +495,10 @@ h5dget_storage_size_c(hid_t_f *dset_id, hsize_t_f *size) c_dset_id = (hid_t)*dset_id; c_size = H5Dget_storage_size(c_dset_id); - if (c_size == 0) - return ret_value; - *size = (hsize_t_f)c_size; - ret_value = 0; + if (c_size != 0) { + ret_value = 0; + } + *size = (hsize_t_f)c_size; return ret_value; } @@ -783,7 +783,7 @@ h5dwrite_vl_string_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_ return ret_value; } /* - * Move data from temorary buffer + * Move data from temporary buffer */ tmp_p = tmp; for (i = 0; i < num_elem; i++) { diff --git a/fortran/src/H5Dff.F90 b/fortran/src/H5Dff.F90 index 75af58e..6b77a8c 100644 --- a/fortran/src/H5Dff.F90 +++ b/fortran/src/H5Dff.F90 @@ -476,7 +476,7 @@ CONTAINS ! ! Changed name from the now obsolete h5dextend_f ! to h5dset_extent_f. Provided interface to old name -! for backward compatability. -MSB- March 14, 2008 +! for backward compatibility. -MSB- March 14, 2008 ! ! SOURCE SUBROUTINE h5dset_extent_f(dataset_id, size, hdferr) @@ -1195,7 +1195,7 @@ CONTAINS IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier - INTEGER(HSIZE_T), DIMENSION(*), INTENT(IN) :: dims ! size of the bufffer buf + INTEGER(HSIZE_T), DIMENSION(*), INTENT(IN) :: dims ! size of the buffer buf TYPE(hobj_ref_t_f), DIMENSION(dims(1)), INTENT(IN), TARGET :: buf ! Data buffer INTEGER, INTENT(OUT) :: hdferr ! Error code INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id ! Memory dataspace identfier @@ -1227,7 +1227,7 @@ CONTAINS IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier - INTEGER(HSIZE_T), DIMENSION(*), INTENT(IN) :: dims ! size of the bufffer buf + INTEGER(HSIZE_T), DIMENSION(*), INTENT(IN) :: dims ! size of the buffer buf TYPE(hdset_reg_ref_t_f), DIMENSION(dims(1)), INTENT(IN), TARGET :: buf ! Data buffer INTEGER, INTENT(OUT) :: hdferr ! Error code INTEGER(HID_T), OPTIONAL, INTENT(IN) :: mem_space_id ! Memory dataspace identfier @@ -1625,8 +1625,7 @@ CONTAINS ! Inputs: ! fill_value - fill value ! space_id - memory space selection identifier -! buf - data buffer iin memory ro apply selection to -! - of k-th dimension of the buf array +! buf - memory buffer containing the selection to be filled ! Outputs: ! hdferr: - error code ! Success: 0 @@ -1676,8 +1675,7 @@ CONTAINS ! Inputs: ! fill_value - fill value ! space_id - memory space selection identifier -! buf - data buffer iin memory ro apply selection to -! - of k-th dimension of the buf array +! buf - memory buffer containing the selection to be filled ! Outputs: ! hdferr: - error code ! Success: 0 @@ -1724,8 +1722,7 @@ CONTAINS ! Inputs: ! fill_value - fill value ! space_id - memory space selection identifier - ! buf - data buffer iin memory ro apply selection to - ! - of k-th dimension of the buf array + ! buf - memory buffer containing the selection to be filled ! Outputs: ! hdferr: - error code ! Success: 0 @@ -1799,8 +1796,7 @@ CONTAINS ! Inputs: ! fill_value - fill value ! space_id - memory space selection identifier -! buf - data buffer iin memory ro apply selection to -! - of k-th dimension of the buf array +! buf - memory buffer containing the selection to be filled ! Outputs: ! hdferr: - error code ! Success: 0 diff --git a/fortran/src/H5Ff.c b/fortran/src/H5Ff.c index f943200..339f8b7 100644 --- a/fortran/src/H5Ff.c +++ b/fortran/src/H5Ff.c @@ -583,7 +583,7 @@ h5fget_name_c(hid_t_f *obj_id, size_t_f *size, _fcd buf, size_t_f *buflen) int_f ret_value = 0; /* Return value */ /* - * Allocate buffer to hold name of an attribute + * Allocate buffer to hold name of file */ if (NULL == (c_buf = (char *)HDmalloc((size_t)*buflen + 1))) HGOTO_DONE(FAIL); @@ -591,7 +591,7 @@ h5fget_name_c(hid_t_f *obj_id, size_t_f *size, _fcd buf, size_t_f *buflen) /* * Call H5Fget_name function */ - if ((size_c = H5Fget_name((hid_t)*obj_id, c_buf, (size_t)*buflen)) < 0) + if ((size_c = H5Fget_name((hid_t)*obj_id, c_buf, (size_t)*buflen + 1)) < 0) HGOTO_DONE(FAIL); /* diff --git a/fortran/src/H5Fff.F90 b/fortran/src/H5Fff.F90 index a273431..ecb40b7 100644 --- a/fortran/src/H5Fff.F90 +++ b/fortran/src/H5Fff.F90 @@ -97,7 +97,7 @@ CONTAINS INTEGER(HID_T), INTENT(OUT) :: file_id ! File identifier INTEGER, INTENT(OUT) :: hdferr ! Error code INTEGER(HID_T), OPTIONAL, INTENT(IN) :: creation_prp - ! File creation propertly + ! File creation property ! list identifier INTEGER(HID_T), OPTIONAL, INTENT(IN) :: access_prp ! File access property list diff --git a/fortran/src/H5Gf.c b/fortran/src/H5Gf.c index f445fee..0201761 100644 --- a/fortran/src/H5Gf.c +++ b/fortran/src/H5Gf.c @@ -390,13 +390,13 @@ DONE: * Call H5Glink2 to link the specified type * INPUTS * cur_loc_id - identifier of file or group - * cur_name - name of the existing object for hard link releative + * cur_name - name of the existing object for hard link relative * to cur_loc_id location, * anything for the soft link * current_namelen - current name length * link_type - link type * new_loc_id - location identifier - * new_name - new name for the object releative to the new_loc_id + * new_name - new name for the object relative to the new_loc_id * location * new_namelen - new_name length * RETURNS @@ -879,7 +879,7 @@ done: * February 15, 2008 * HISTORY * - * - Added 'mounted' paramater + * - Added 'mounted' parameter * M. Scot Breitenfeld * July 16, 2008 * SOURCE @@ -1014,7 +1014,7 @@ done: * February 18, 2008 * HISTORY * - * - Added 'mounted' paramater + * - Added 'mounted' parameter * M. Scot Breitenfeld * July 16, 2008 * SOURCE diff --git a/fortran/src/H5Gff.F90 b/fortran/src/H5Gff.F90 index 9e7665f..bfca595 100644 --- a/fortran/src/H5Gff.F90 +++ b/fortran/src/H5Gff.F90 @@ -73,7 +73,7 @@ CONTAINS ! called C functions (it is needed for Windows ! port). March 5, 2001 ! -! Added additional optional paramaters in 1.8 +! Added additional optional parameters in 1.8 ! MSB - February 27, 2008 ! ! SOURCE @@ -491,8 +491,8 @@ CONTAINS INTEGER, INTENT(OUT) :: hdferr ! Error code !***** - INTEGER :: current_namelen ! Lenghth of the current_name string - INTEGER :: new_namelen ! Lenghth of the new_name string + INTEGER :: current_namelen ! Length of the current_name string + INTEGER :: new_namelen ! Length of the new_name string INTERFACE INTEGER FUNCTION h5glink_c(loc_id, link_type, current_name, & @@ -524,7 +524,7 @@ CONTAINS ! PURPOSE ! Creates a link of the specified type from new_name ! to current_name. current_name and new_name are interpreted -! releative to current and new location identifiers. +! relative to current and new location identifiers. ! ! INPUTS ! cur_loc_id - location identifier @@ -559,8 +559,8 @@ CONTAINS INTEGER, INTENT(OUT) :: hdferr ! Error code !***** - INTEGER :: cur_namelen ! Lenghth of the current_name string - INTEGER :: new_namelen ! Lenghth of the new_name string + INTEGER :: cur_namelen ! Length of the current_name string + INTEGER :: new_namelen ! Length of the new_name string INTERFACE INTEGER FUNCTION h5glink2_c(cur_loc_id, cur_name, cur_namelen, & @@ -617,7 +617,7 @@ CONTAINS CHARACTER(LEN=*), INTENT(IN) :: name ! Name of an object INTEGER, INTENT(OUT) :: hdferr ! Error code !***** - INTEGER :: namelen ! Lenghth of the name character string + INTEGER :: namelen ! Length of the name character string INTERFACE INTEGER FUNCTION h5gunlink_c(loc_id, name, namelen) BIND(C,NAME='h5gunlink_c') @@ -666,8 +666,8 @@ CONTAINS CHARACTER(LEN=*), INTENT(IN) :: new_name ! New name of an object INTEGER, INTENT(OUT) :: hdferr ! Error code !***** - INTEGER :: namelen ! Lenghth of the current_name string - INTEGER :: new_namelen ! Lenghth of the new_name string + INTEGER :: namelen ! Length of the current_name string + INTEGER :: new_namelen ! Length of the new_name string INTERFACE INTEGER FUNCTION h5gmove_c(loc_id, name, namelen, new_name, new_namelen) BIND(C,NAME='h5gmove_c') @@ -715,7 +715,7 @@ CONTAINS INTEGER, INTENT(OUT) :: hdferr ! Error code !***** INTEGER :: src_namelen ! Length of the current_name string - INTEGER :: dst_namelen ! Lenghth of the new_name string + INTEGER :: dst_namelen ! Length of the new_name string INTERFACE INTEGER FUNCTION h5gmove2_c(src_loc_id, src_name, src_namelen, & @@ -776,7 +776,7 @@ CONTAINS ! points to INTEGER, INTENT(OUT) :: hdferr ! Error code !***** - INTEGER :: namelen ! Lenghth of the current_name string + INTEGER :: namelen ! Length of the current_name string INTERFACE INTEGER FUNCTION h5gget_linkval_c(loc_id, name, namelen, size, buffer) BIND(C,NAME='h5gget_linkval_c') @@ -827,8 +827,8 @@ CONTAINS CHARACTER(LEN=*), INTENT(IN) :: comment ! New name of an object INTEGER, INTENT(OUT) :: hdferr ! Error code !***** - INTEGER :: namelen ! Lenghth of the current_name string - INTEGER :: commentlen ! Lenghth of the comment string + INTEGER :: namelen ! Length of the current_name string + INTEGER :: commentlen ! Length of the comment string INTERFACE INTEGER FUNCTION h5gset_comment_c(loc_id, name, namelen, & @@ -1024,7 +1024,7 @@ CONTAINS ! ! HISTORY ! -! - Added 'mounted' paramater +! - Added 'mounted' parameter ! M. Scot Breitenfeld ! July 16, 2008 ! @@ -1104,7 +1104,7 @@ CONTAINS ! February 18, 2008 ! ! HISTORY -! Added 'mounted' paramater +! Added 'mounted' parameter ! M. Scot Breitenfeld ! July 16, 2008 ! @@ -1206,7 +1206,7 @@ CONTAINS ! February 18, 2008 ! ! HISTORY -! Added 'mounted' paramater +! Added 'mounted' parameter ! M. Scot Breitenfeld ! July 16, 2008 ! SOURCE diff --git a/fortran/src/H5Lff.F90 b/fortran/src/H5Lff.F90 index 3bfcf65..a568824 100644 --- a/fortran/src/H5Lff.F90 +++ b/fortran/src/H5Lff.F90 @@ -469,7 +469,7 @@ CONTAINS ! SOURCE SUBROUTINE h5ldelete_by_idx_f(loc_id, group_name, index_field, order, n, hdferr, lapl_id) IMPLICIT NONE - INTEGER(HID_T), INTENT(IN) :: loc_id ! Identifer for object to which attribute is attached + INTEGER(HID_T), INTENT(IN) :: loc_id ! Identifier for object to which attribute is attached CHARACTER(LEN=*), INTENT(IN) :: group_name ! Name of object, relative to location, ! from which attribute is to be removed INTEGER, INTENT(IN) :: index_field ! Type of index; Possible values are: @@ -1315,7 +1315,7 @@ CONTAINS ! Inputs: ! group_id - Identifier specifying subject group ! index_type - Type of index which determines the order: -! H5_INDEX_NAME_F - Alpha-numeric index on name +! H5_INDEX_NAME_F - Alphanumeric index on name ! H5_INDEX_CRT_ORDER_F - Index on creation order ! order - Order within index: ! H5_ITER_INC_F - Increasing order @@ -1391,7 +1391,7 @@ CONTAINS ! loc_id - File or group identifier specifying location of subject group ! group_name - Name of subject group ! index_type - Type of index which determines the order: -! H5_INDEX_NAME_F - Alpha-numeric index on name +! H5_INDEX_NAME_F - Alphanumeric index on name ! H5_INDEX_CRT_ORDER_F - Index on creation order ! order - Order within index: ! H5_ITER_INC_F - Increasing order diff --git a/fortran/src/H5Pf.c b/fortran/src/H5Pf.c index 1f74955..ab09ab9 100644 --- a/fortran/src/H5Pf.c +++ b/fortran/src/H5Pf.c @@ -145,7 +145,7 @@ done: * plist1_id - property list identifier * plist2_id - property list identifier * OUTPUTS - * c_flag - flag to indicate that lists are eqaul + * c_flag - flag to indicate that lists are equal * RETURNS * 0 on success, -1 on failure * AUTHOR @@ -936,7 +936,7 @@ h5pset_fapl_stdio_c(hid_t_f *prp_id) * NAME * h5pget_fapl_stdio_c * PURPOSE - * Call H5Pget_fapl_stdio to determine whther the low level file driver + * Call H5Pget_fapl_stdio to determine whether the low level file driver * uses the functions declared in the stdio.h * INPUTS * prp_id - property list identifier @@ -1013,7 +1013,7 @@ h5pset_fapl_sec2_c(hid_t_f *prp_id) * NAME * h5pget_fapl_sec2_c * PURPOSE - * Call H5Pget_fapl_stdio to determine whther the low level file driver + * Call H5Pget_fapl_stdio to determine whether the low level file driver * uses the functions declared in the unistd.h * INPUTS * prp_id - property list identifier @@ -2186,7 +2186,7 @@ h5pset_fclose_degree_c(hid_t_f *fapl_id, int_f *degree) * PURPOSE * Call H5Pset_buffer to set size of conversion buffer * INPUTS - * prp_id - t`dataset trasfer property list identifier + * prp_id - t`dataset transfer property list identifier * size - size of the buffer * OUTPUTS * NONE @@ -2221,7 +2221,7 @@ h5pset_buffer_c(hid_t_f *prp_id, hsize_t_f *size) * PURPOSE * Call H5Pget_buffer to get size of conversion buffer * INPUTS - * prp_id - t`dataset trasfer property list identifier + * prp_id - t`dataset transfer property list identifier * OUTPUTS * size - size of conversion buffer * RETURNS @@ -3005,11 +3005,11 @@ h5pget_nprops_c(hid_t_f *plist, size_t_f *nprops) * h5pget_class_parent_c * PURPOSE * Call H5Pget_class_parent to get the parent class of - * a genereic property class + * a generic property class * INPUTS * prp_id - property list to query * OUTPUTS - * parent_id - parent classs identifier + * parent_id - parent class identifier * RETURNS * 0 on success, -1 on failure * AUTHOR @@ -3505,7 +3505,7 @@ h5pset_family_offset_c(hid_t_f *prp_id, hsize_t_f *offset) * NAME * h5pset_fapl_multi_c * PURPOSE - * Call H5Pset_fapl_multi to set multi file dirver + * Call H5Pset_fapl_multi to set multi file driver * INPUTS * prp_id - file_creation property list identifier * mem_map - memory mapping array @@ -3570,7 +3570,7 @@ h5pset_fapl_multi_c(hid_t_f *prp_id, int_f *memb_map, hid_t_f *memb_fapl, _fcd m tmp_p = tmp_p + c_lenmax; } /* - * Take care of othe arguments + * Take care of other arguments */ tmp_max_addr = (long double)(HADDR_MAX); c_prp_id = (hid_t)*prp_id; @@ -3603,7 +3603,7 @@ DONE: * NAME * h5pset_fapl_multi_sc * PURPOSE - * Call H5Pset_fapl_multi to set multi file dirver + * Call H5Pset_fapl_multi to set multi file driver * INPUTS * prp_id - file_creation property list identifier * RETURNS @@ -3641,7 +3641,7 @@ h5pset_fapl_multi_sc(hid_t_f *prp_id, int_f *flag) * NAME * h5pget_fapl_multi_c * PURPOSE - * Call H5Pget_fapl_multi to set multi file dirver + * Call H5Pget_fapl_multi to set multi file driver * INPUTS * prp_id - file_creation property list identifier * lenmax - length of the name a sdeclared in Fortran @@ -4607,7 +4607,7 @@ h5pget_copy_object_c(hid_t_f *ocp_plist_id, int_f *copy_options) * INPUTS * * prp_id - property list identifier to query - * expression_len - buffer size transorm expression + * expression_len - buffer size transform expression * * Output: * expression - buffer to hold transform expression @@ -4670,7 +4670,7 @@ done: * * prp_id - property list identifier to query * expression - buffer to hold transform expression - * expression_len - buffer size transorm expression + * expression_len - buffer size transform expression * * Output: * @@ -5478,7 +5478,7 @@ h5pget_fapl_mpio_c(hid_t_f *prp_id, int_f *comm, int_f *info) * h5pset_dxpl_mpio_c * PURPOSE * Call H5Pset_dxpl_mpio to set transfer mode of the dataset - * trasfer property list + * transfer property list * INPUTS * prp_id - property list identifier * data_xfer_mode - transfer mode @@ -5530,7 +5530,7 @@ h5pset_dxpl_mpio_c(hid_t_f *prp_id, int_f *data_xfer_mode) * h5pget_dxpl_mpio_c * PURPOSE * Call H5Pget_dxpl_mpio to get transfer mode of the dataset - * trasfer property list + * transfer property list * INPUTS * prp_id - property list identifier * data_xfer_mode - buffer to retrieve transfer mode diff --git a/fortran/src/H5Pff.F90 b/fortran/src/H5Pff.F90 index a7f2366..c55b7d9 100644 --- a/fortran/src/H5Pff.F90 +++ b/fortran/src/H5Pff.F90 @@ -500,7 +500,7 @@ CONTAINS ! a chunked layout dataset. ! ! INPUTS -! prp_id - datatset creation property list identifier +! prp_id - dataset creation property list identifier ! ndims - number of dimensions for each chunk ! dims - array with dimension sizes for each chunk ! OUTPUTS @@ -1880,7 +1880,7 @@ CONTAINS ! INPUTS ! ! prp_id - file access property list identifier -! gc_reference - flag for stting garbage collection on +! gc_reference - flag for setting garbage collection on ! and off (1 or 0) ! OUTPUTS ! @@ -1931,7 +1931,7 @@ CONTAINS ! prp_id - file access property list identifier ! OUTPUTS ! -! gc_reference - flag for stting garbage collection on +! gc_reference - flag for setting garbage collection on ! and off (1 or 0) ! hdferr - error code ! Success: 0 @@ -2659,7 +2659,7 @@ CONTAINS ! h5pequal_f ! ! PURPOSE -! Checks if two property lists are eqaul +! Checks if two property lists are equal ! ! INPUTS ! @@ -3059,7 +3059,7 @@ CONTAINS ! INPUTS ! ! plist_id - file access property list identifier -! size - metatdata block size +! size - metadata block size ! OUTPUTS ! ! hdferr - error code @@ -3103,7 +3103,7 @@ CONTAINS ! plist_id - file access property list identifier ! OUTPUTS ! -! size - metatdata block size +! size - metadata block size ! hdferr - error code ! Success: 0 ! Failure: -1 @@ -3596,7 +3596,7 @@ CONTAINS ! h5pget_class_parent_f ! ! PURPOSE -! Retrieves the parent class of a genric property class. +! Retrieves the parent class of a generic property class. ! ! INPUTS ! @@ -5391,7 +5391,7 @@ CONTAINS ! ! HISTORY ! -! Should hdferr return just 0 or 1 and add another arguement for the size? +! Should hdferr return just 0 or 1 and add another argument for the size? ! Fortran90 Interface: SUBROUTINE h5pget_data_transform_f(plist_id, expression, hdferr, size) IMPLICIT NONE diff --git a/fortran/src/H5Sf.c b/fortran/src/H5Sf.c index 341acfd..ea42a31 100644 --- a/fortran/src/H5Sf.c +++ b/fortran/src/H5Sf.c @@ -388,7 +388,7 @@ done: * PURPOSE * Call H5Sget_select_elem_pointlist * get a list of element points in the - * current dataspace selectin. + * current dataspace selection. * Starting with the startpoint-th point in the * list of points, numpoints points are put into the user's * buffer. If the user's buffer fills up before numpoints @@ -759,7 +759,7 @@ done: * space_id - identifier of the dataspace * rank - dataspace rank * current_size - array with the new dimension sizes - * maximum_size - aray with maximum sizes of dimensions + * maximum_size - array with maximum sizes of dimensions * RETURNS * 0 on success, -1 on failure * AUTHOR @@ -804,7 +804,7 @@ done: * space_id - identifier of the dataspace * OUTPUTS * dims - array with the dimension sizes - * maxdims - aray with maximum sizes of dimensions + * maxdims - array with maximum sizes of dimensions * RETURNS * number of dataspace dimensions (rank) on success, -1 on failure * AUTHOR @@ -852,7 +852,7 @@ done: * NAME * h5sis_simple_c * PURPOSE - * Call H5Sis_simple to detrmine if the dataspace + * Call H5Sis_simple to determine if the dataspace * is simple. * INPUTS * space_id - identifier of the dataspace diff --git a/fortran/src/H5Sff.F90 b/fortran/src/H5Sff.F90 index 62d665a..76b0dea 100644 --- a/fortran/src/H5Sff.F90 +++ b/fortran/src/H5Sff.F90 @@ -447,7 +447,7 @@ CONTAINS ! INPUTS ! space_id - dataspace identifier ! startpoint - element point to start with -! num_points - number of elemnt points to get +! num_points - number of element points to get ! OUTPUTS ! buf - buffer with element points selected ! hdferr - Returns 0 if successful and -1 if fails diff --git a/fortran/src/H5Tf.c b/fortran/src/H5Tf.c index 1516cc7..f3016f1 100644 --- a/fortran/src/H5Tf.c +++ b/fortran/src/H5Tf.c @@ -1560,7 +1560,7 @@ h5tget_member_type_c(hid_t_f *type_id, int_f *field_idx, hid_t_f *datatype) * Call H5Tcreate to create a datatype * INPUTS * cls - class type - * size - size of the class memeber + * size - size of the class member * RETURNS * 0 on success, -1 on failure * AUTHOR @@ -2033,7 +2033,7 @@ h5tvlen_create_c(hid_t_f *type_id, hid_t_f *vltype_id) * NAME * h5tis_variable_str_c * PURPOSE - * Call H5Tis_variable_str to detrmine if the datatype + * Call H5Tis_variable_str to determine if the datatype * is a variable string. * INPUTS * type_id - identifier of the dataspace @@ -2069,7 +2069,7 @@ h5tis_variable_str_c(hid_t_f *type_id, int_f *flag) * NAME * h5tget_member_class_c * PURPOSE - * Call H5Tget_member_class to detrmine ithe class of the compound + * Call H5Tget_member_class to determine ithe class of the compound * datatype member * INPUTS * type_id - identifier of the dataspace diff --git a/fortran/src/H5Tff.F90 b/fortran/src/H5Tff.F90 index 0eab39e..7582dab 100644 --- a/fortran/src/H5Tff.F90 +++ b/fortran/src/H5Tff.F90 @@ -86,7 +86,7 @@ CONTAINS ! called C functions (it is needed for Windows ! port). March 7, 2001 ! -! Added optional parameter 'tapl_id' for compatability +! Added optional parameter 'tapl_id' for compatibility ! with H5Topen2. April 9, 2009. ! ! SOURCE @@ -212,7 +212,7 @@ CONTAINS ! h5tcopy_f ! ! PURPOSE -! Creates a copy of exisiting datatype. +! Creates a copy of existing datatype. ! ! INPUTS ! type_id - datatype identifier diff --git a/fortran/src/H5_buildiface.F90 b/fortran/src/H5_buildiface.F90 index fb3a002..090b6db 100644 --- a/fortran/src/H5_buildiface.F90 +++ b/fortran/src/H5_buildiface.F90 @@ -14,7 +14,7 @@ ! ! NOTES ! This program uses the Fortran 2008 intrinsic function STORAGE_SIZE or SIZEOF -! depending on availablity.It generates code that makes use of +! depending on availability.It generates code that makes use of ! STORAGE_SIZE/SIZEOF in H5_gen.F90. STORAGE_SIZE is standard ! compliant and should always be chosen over SIZEOF. ! @@ -437,7 +437,7 @@ PROGRAM H5_buildiface ! dims parameter was added to make code portable; ! Aprile 4, 2001 ! -! Changed buf intent to INOUT to be consistant +! Changed buf intent to INOUT to be consistent ! with how the C functions handles it. The pg ! compiler will return 0 if a buf value is not set. ! February, 2008 @@ -564,7 +564,7 @@ PROGRAM H5_buildiface ! dims parameter was added to make code portable; ! Aprile 4, 2001 ! -! Changed buf intent to INOUT to be consistant +! Changed buf intent to INOUT to be consistent ! with how the C functions handles it. The pg ! compiler will return 0 if a buf value is not set. ! February, 2008 @@ -677,7 +677,7 @@ PROGRAM H5_buildiface ! Optional parameters: ! mem_space_id - memory dataspace identifier ! file_space_id - file dataspace identifier -! xfer_prp - trasfer property list identifier +! xfer_prp - transfer property list identifier ! ! AUTHOR ! Elena Pourmal diff --git a/fortran/src/H5_ff.F90 b/fortran/src/H5_ff.F90 index ebf888c..6715314 100644 --- a/fortran/src/H5_ff.F90 +++ b/fortran/src/H5_ff.F90 @@ -700,7 +700,7 @@ CONTAINS ! ! Outputs: ! majnum - major version of the library -! minum - minor version of the library +! minnum - minor version of the library ! relnum - release version of the library ! error - Returns 0 if successful and -1 if fails ! @@ -735,7 +735,7 @@ CONTAINS ! ! Inputs: ! majnum - major version of the library -! minum - minor version of the library +! minnum - minor version of the library ! relnum - release version of the library ! ! Outputs: diff --git a/fortran/src/H5f90global.F90 b/fortran/src/H5f90global.F90 index 0ed8a17..d202547 100644 --- a/fortran/src/H5f90global.F90 +++ b/fortran/src/H5f90global.F90 @@ -853,7 +853,7 @@ CONTAINS END SUBROUTINE H5_Fortran_string_f2c -! Copy Fortran string to C charater array, assuming the C array is one-char +! Copy Fortran string to C character array, assuming the C array is one-char ! longer for the terminating null char. ! fstring : the Fortran input string ! cstring : the C output string (with memory already allocated) @@ -881,7 +881,7 @@ CONTAINS !!$ cstring(j) = C_NULL_CHAR !!$end subroutine MPIR_Fortran_string_f2c !!$ -!!$! Copy C charater array to Fortran string +!!$! Copy C character array to Fortran string !!$subroutine MPIR_Fortran_string_c2f(cstring, fstring) !!$ implicit none !!$ character(kind=c_char), intent(in) :: cstring(:) diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h index fbbf7c2..4aa33f6 100644 --- a/fortran/src/H5f90proto.h +++ b/fortran/src/H5f90proto.h @@ -540,7 +540,7 @@ H5_FCDLL int_f h5pget_dxpl_mpio_c(hid_t_f *prp_id, int_f *data_xfer_mode); H5_FCDLL int_f h5pset_dxpl_mpio_c(hid_t_f *prp_id, int_f *data_xfer_mode); #endif /* - * Functions frome H5Rf.c + * Functions from H5Rf.c */ H5_FCDLL int_f h5rcreate_region_c(int_f *ref, hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *space_id); H5_FCDLL int_f h5rcreate_ptr_c(void *ref, hid_t_f *loc_id, _fcd name, int_f *namelen, int_f *ref_type, diff --git a/fortran/src/h5fc.in b/fortran/src/h5fc.in index a56d38d..661fde5 100644 --- a/fortran/src/h5fc.in +++ b/fortran/src/h5fc.in @@ -38,7 +38,7 @@ HL="@HL@" ## $FLINKER $FCFLAGS $H5BLD_FCFLAGS $F9XSUFFIXFLAG $LDFLAGS $LIBS ## ## $fmodules $link_objs $link_args $shared_link ## ## ## -## These settings can be overriden by setting HDF5_FCFLAGS, ## +## These settings can be overridden by setting HDF5_FCFLAGS, ## ## HDF5_LDFLAGS, or HDF5_LIBS in the environment. ## ## ## ############################################################################ @@ -136,7 +136,7 @@ usage() { echo " shared libraries]" echo " " echo " You can also add or change paths and flags to the compile line using" - echo " the following environment varibles or by assigning them to their counterparts" + echo " the following environment variables or by assigning them to their counterparts" echo " in the 'Things You Can Modify to Override...'" section of $prog_name echo " " echo " Variable Current value to be replaced" @@ -298,7 +298,7 @@ fi if test "x$do_link" = "xyes"; then shared_link="" -# conditionnaly link with the hl library +# conditionally link with the hl library if test "X$HL" = "Xhl"; then libraries=" $libraries -lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 " else diff --git a/fortran/test/H5_test_buildiface.F90 b/fortran/test/H5_test_buildiface.F90 index 94beab1..302fa38 100644 --- a/fortran/test/H5_test_buildiface.F90 +++ b/fortran/test/H5_test_buildiface.F90 @@ -14,7 +14,7 @@ ! ! NOTES ! This program uses the Fortran 2008 intrinsic function STORAGE_SIZE or SIZEOF -! depending on availablity.It generates code that makes use of +! depending on availability.It generates code that makes use of ! STORAGE_SIZE/SIZEOF in H5fortran_detect.f90. STORAGE_SIZE is standard ! compliant and should always be chosen over SIZEOF. ! diff --git a/fortran/test/fflush1.F90 b/fortran/test/fflush1.F90 index c192d93..5684f81 100644 --- a/fortran/test/fflush1.F90 +++ b/fortran/test/fflush1.F90 @@ -88,7 +88,7 @@ data_dims(2) = NY ! - !Initialize FORTRAN predifined datatypes + !Initialize FORTRAN predefined datatypes ! CALL h5open_f(error) CALL check("h5open_f",error,total_error) diff --git a/fortran/test/fflush2.F90 b/fortran/test/fflush2.F90 index dc3bc85..a6e16c1 100644 --- a/fortran/test/fflush2.F90 +++ b/fortran/test/fflush2.F90 @@ -81,7 +81,7 @@ PROGRAM FFLUSH2EXAMPLE data_dims(2) = NY ! - !Initialize FORTRAN predifined datatypes + !Initialize FORTRAN predefined datatypes ! CALL h5open_f(error) CALL check("h5open_f",error,total_error) @@ -163,7 +163,7 @@ PROGRAM FFLUSH2EXAMPLE CALL check("h5fclose_f",error,total_error) ! - !Close FORTRAN predifined datatypes + !Close FORTRAN predefined datatypes ! CALL h5_cleanup_f(filename, H5P_DEFAULT_F, error) CALL h5close_f(error) diff --git a/fortran/test/tH5A.F90 b/fortran/test/tH5A.F90 index d5ce9a2..2e76dad 100644 --- a/fortran/test/tH5A.F90 +++ b/fortran/test/tH5A.F90 @@ -81,7 +81,7 @@ CONTAINS INTEGER(HID_T) :: atype5_id !Integer Attribute Datatype identifier INTEGER(HSIZE_T), DIMENSION(1) :: adims = (/2/) ! Attribute dimension INTEGER(HSIZE_T), DIMENSION(1) :: adims2 = (/1/) ! Attribute dimension - INTEGER :: arank = 1 ! Attribure rank + INTEGER :: arank = 1 ! Attribute rank INTEGER(SIZE_T) :: attrlen ! Length of the attribute string INTEGER(HID_T) :: attr_space !Returned String Attribute Space identifier diff --git a/fortran/test/tH5A_1_8.F90 b/fortran/test/tH5A_1_8.F90 index 4e02c58..cd8a981 100644 --- a/fortran/test/tH5A_1_8.F90 +++ b/fortran/test/tH5A_1_8.F90 @@ -64,7 +64,7 @@ SUBROUTINE attribute_test_1_8(cleanup, total_error) INTEGER :: ret_total_error ! ******************** -! test_attr equivelent +! test_attr equivalent ! ******************** ! WRITE(*,*) "TESTING ATTRIBUTES" @@ -776,8 +776,7 @@ SUBROUTINE test_attr_info_by_idx(new_format, fcpl, fapl, total_error) INTEGER :: Input1 INTEGER(HSIZE_T) :: hzero = 0_HSIZE_T - INTEGER :: minusone = -1 - INTEGER(HSIZE_T) :: htmp + INTEGER, PARAMETER :: minusone = -1 data_dims = 0 @@ -840,10 +839,6 @@ SUBROUTINE test_attr_info_by_idx(new_format, fcpl, fapl, total_error) my_dataset = dset3 END SELECT - ! Check for query on non-existant attribute - - n = 0 - ! -- CHECK PASSING AN INTEGER CONSTANT IN DIFFERENT FORMS -- ! 1) call by passing an integer with the _hsize_t declaration @@ -896,8 +891,8 @@ SUBROUTINE test_attr_info_by_idx(new_format, fcpl, fapl, total_error) ! Verify information for new attribute !EP CALL attr_info_by_idx_check(my_dataset, attrname, INT(j,HSIZE_T), use_index(i), total_error ) - htmp = j - CALL attr_info_by_idx_check(my_dataset, attrname, htmp, use_index(i), total_error ) + n = INT(j, HSIZE_T) + CALL attr_info_by_idx_check(my_dataset, attrname, n, use_index(i), total_error ) !CHECK(ret, FAIL, "attr_info_by_idx_check"); ENDDO @@ -1111,7 +1106,7 @@ SUBROUTINE test_attr_shared_rename( fcpl, fapl, total_error) INTEGER :: test_shared INTEGER(HSIZE_T), DIMENSION(1) :: adims2 = (/1/) ! Attribute dimension - INTEGER :: arank = 1 ! Attribure rank + INTEGER :: arank = 1 ! Attribute rank ! Initialize "big" attribute data @@ -1427,7 +1422,7 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) INTEGER :: u ! Local index variable INTEGER :: Input1 INTEGER(HSIZE_T) :: hzero = 0_HSIZE_T - INTEGER :: minusone = -1 + INTEGER, PARAMETER :: minusone = -1 data_dims = 0 @@ -1497,7 +1492,7 @@ SUBROUTINE test_attr_delete_by_idx(new_format, fcpl, fapl, total_error) END SELECT - ! Check for deleting non-existant attribute + ! Check for deleting non-existent attribute !EP CALL H5Adelete_by_idx_f(my_dataset, '.', idx_type, order, 0_HSIZE_T,error, lapl_id=H5P_DEFAULT_F) CALL H5Adelete_by_idx_f(my_dataset, '.', idx_type, order, hzero,error, lapl_id=H5P_DEFAULT_F) CALL verify("H5Adelete_by_idx_f",error,minusone,total_error) @@ -1773,7 +1768,7 @@ SUBROUTINE test_attr_shared_delete(fcpl, fapl, total_error) INTEGER :: test_shared INTEGER(HSIZE_T), DIMENSION(1) :: adims2 = (/1/) ! Attribute dimension - INTEGER :: arank = 1 ! Attribure rank + INTEGER :: arank = 1 ! Attribute rank ! Output message about test being performed @@ -2268,7 +2263,7 @@ SUBROUTINE test_attr_corder_create_basic( fcpl, fapl, total_error ) INTEGER :: error INTEGER :: crt_order_flags - INTEGER :: minusone = -1 + INTEGER, PARAMETER :: minusone = -1 ! Output message about test being performed ! WRITE(*,*) " - Testing Basic Code for Attributes with Creation Order Info" diff --git a/fortran/test/tH5D.F90 b/fortran/test/tH5D.F90 index 006d62a..eb9e831 100644 --- a/fortran/test/tH5D.F90 +++ b/fortran/test/tH5D.F90 @@ -187,7 +187,7 @@ CONTAINS DO i = 1, 4 DO j = 1, 6 IF (data_out(i,j) .NE. dset_data(i, j)) THEN - WRITE(*, *) "dataset test error occured" + WRITE(*, *) "dataset test error occurred" WRITE(*,*) "data read is not the same as the data written" END IF END DO @@ -196,7 +196,7 @@ CONTAINS ! Check if no change to null_dset_data ! IF (null_dset_data .NE. 1) THEN - WRITE(*, *) "null dataset test error occured" + WRITE(*, *) "null dataset test error occurred" END IF ! ! End access to the dataset and release resources used by it. @@ -258,7 +258,7 @@ CONTAINS INTEGER(HID_T) :: dset_id ! Dataset identifier INTEGER(HID_T) :: dataspace ! Dataspace identifier INTEGER(HID_T) :: memspace ! memory Dataspace identifier - INTEGER(HID_T) :: crp_list ! dataset creatation property identifier + INTEGER(HID_T) :: crp_list ! dataset creation property identifier ! !dataset dimensions at creation time @@ -313,7 +313,7 @@ CONTAINS END DO ! - !Initialize FORTRAN predifined datatypes + !Initialize FORTRAN predefined datatypes ! ! CALL h5init_types_f(error) ! CALL check("h5init_types_f",error,total_error) @@ -347,7 +347,7 @@ CONTAINS CALL check("h5pset_chunk_f",error,total_error) ! - !Create a dataset with 3X3 dimensions using cparms creation propertie . + !Create a dataset with 3X3 dimensions using cparms creation properties . ! CALL h5dcreate_f(file_id, dsetname, H5T_NATIVE_INTEGER, dataspace, dset_id, error, crp_list ) CALL check("h5dcreate_f",error,total_error) @@ -426,7 +426,7 @@ CONTAINS CALL h5sget_simple_extent_ndims_f(dataspace, rankr, error) CALL check("h5sget_simple_extent_ndims_f",error,total_error) IF (rankr .NE. RANK) THEN - WRITE(*,*) "dataset rank error occured" + WRITE(*,*) "dataset rank error occurred" STOP END IF @@ -436,7 +436,7 @@ CONTAINS CALL h5sget_simple_extent_dims_f(dataspace, dimsr, maxdimsr, error) CALL check("h5sget_simple_extent_dims_f",error,total_error) IF ((dimsr(1) .NE. dims1(1)) .OR. (dimsr(2) .NE. dims1(2))) THEN - WRITE(*,*) "dataset dimensions error occured" + WRITE(*,*) "dataset dimensions error occurred" STOP END IF @@ -466,7 +466,7 @@ CONTAINS DO ih = 1, dims1(1) DO jh = 1, dims1(2) IF (data_out(ih,jh) .NE. data_in(ih, jh)) THEN - WRITE(*, *) "extend dataset test error occured" + WRITE(*, *) "extend dataset test error occurred" WRITE(*, *) "read value is not the same as the written values" END IF END DO diff --git a/fortran/test/tH5F.F90 b/fortran/test/tH5F.F90 index 06dc6de..8d4845d 100644 --- a/fortran/test/tH5F.F90 +++ b/fortran/test/tH5F.F90 @@ -554,7 +554,7 @@ CONTAINS do i = 1, NX do j = 1, NY IF (data_out(i,j) .NE. dset_data(i, j)) THEN - write(*, *) "reopen test error occured" + write(*, *) "reopen test error occurred" END IF end do end do @@ -584,17 +584,23 @@ CONTAINS ! The following subroutine checks that h5fget_name_f produces ! correct output for a given obj_id and filename. ! - SUBROUTINE check_get_name(obj_id, fix_filename, total_error) + SUBROUTINE check_get_name(obj_id, fix_filename, len_filename, total_error) USE HDF5 ! This module contains all necessary modules USE TH5_MISC IMPLICIT NONE INTEGER(HID_T) :: obj_id ! Object identifier CHARACTER(LEN=80), INTENT(IN) :: fix_filename ! Expected filename + INTEGER, INTENT(IN) :: len_filename ! The length of the filename INTEGER, INTENT(INOUT) :: total_error ! Error count CHARACTER(LEN=80):: file_name ! Filename buffer INTEGER:: error ! HDF5 error code INTEGER(SIZE_T):: name_size ! Filename length + + INTEGER, PARAMETER :: sm_len = 2 + CHARACTER(LEN=len_filename) :: filename_exact + CHARACTER(LEN=len_filename-sm_len) :: filename_sm + ! !Get file name from the dataset identifier ! @@ -637,6 +643,30 @@ CONTAINS total_error = total_error + 1 END IF + ! Use a buffer which is the exact size needed to hold the filename + CALL h5fget_name_f(obj_id, filename_exact, name_size, error) + CALL check("h5fget_name_f",error,total_error) + IF(name_size .NE. len_filename)THEN + WRITE(*,*) " file name size obtained from the object id is incorrect" + total_error = total_error + 1 + ENDIF + IF(filename_exact .NE. TRIM(fix_filename)) THEN + WRITE(*,*) " file name obtained from the object id is incorrect" + total_error = total_error + 1 + END IF + + ! Use a buffer which is smaller than needed to hold the filename + CALL h5fget_name_f(obj_id, filename_sm, name_size, error) + CALL check("h5fget_name_f",error,total_error) + IF(name_size .NE. len_filename)THEN + WRITE(*,*) " file name size obtained from the object id is incorrect" + total_error = total_error + 1 + ENDIF + IF(filename_sm(1:len_filename-sm_len) .NE. fix_filename(1:len_filename-sm_len)) THEN + WRITE(*,*) " file name obtained from the object id is incorrect" + total_error = total_error + 1 + END IF + END SUBROUTINE check_get_name ! The following subroutine tests h5fget_name_f. @@ -653,6 +683,7 @@ CONTAINS CHARACTER(LEN=*), PARAMETER :: filename = "filename" CHARACTER(LEN=80) :: fix_filename + INTEGER :: len_filename INTEGER(HID_T) :: file_id ! File identifier INTEGER(HID_T) :: g_id ! Group identifier @@ -679,8 +710,9 @@ CONTAINS CALL h5gopen_f(file_id,"/",g_id, error) CALL check("h5gopen_f",error,total_error) - CALL check_get_name(file_id, fix_filename, total_error) - CALL check_get_name(g_id, fix_filename, total_error) + len_filename = LEN_TRIM(fix_filename) + CALL check_get_name(file_id, fix_filename, len_filename, total_error) + CALL check_get_name(g_id, fix_filename, len_filename, total_error) ! Close the group. ! diff --git a/fortran/test/tH5G_1_8.F90 b/fortran/test/tH5G_1_8.F90 index 534a2d4..222ba9d 100644 --- a/fortran/test/tH5G_1_8.F90 +++ b/fortran/test/tH5G_1_8.F90 @@ -654,7 +654,7 @@ SUBROUTINE group_info(cleanup, fapl, total_error) INTEGER(HID_T) :: file, scalar, grp, d1 CHARACTER(LEN=12), PARAMETER :: filename ='TestLinks.h5' INTEGER(HSIZE_T), DIMENSION(1) :: adims2 = (/1/) ! Attribute dimension - INTEGER :: arank = 1 ! Attribure rank + INTEGER :: arank = 1 ! Attribute rank INTEGER :: error INTEGER :: cset ! Indicates the character set used for the link’s name. diff --git a/fortran/test/tH5MISC_1_8.F90 b/fortran/test/tH5MISC_1_8.F90 index c294f21..e35ef1f 100644 --- a/fortran/test/tH5MISC_1_8.F90 +++ b/fortran/test/tH5MISC_1_8.F90 @@ -160,7 +160,7 @@ SUBROUTINE test_genprop_basic_class(total_error) CALL verify("H5Pequal_f", flag, .TRUE., total_error) - ! Make certain false postives aren't being returned + ! Make certain false positives aren't being returned CALL H5Pequal_f(cid2, H5P_FILE_CREATE_F, flag, error) CALL check("H5Pequal_f", error, total_error) CALL verify("H5Pequal_f", flag, .FALSE., total_error) diff --git a/fortran/test/tH5P.F90 b/fortran/test/tH5P.F90 index 1d1208c..d664dd7 100644 --- a/fortran/test/tH5P.F90 +++ b/fortran/test/tH5P.F90 @@ -349,8 +349,8 @@ SUBROUTINE multi_file_test(cleanup, total_error) DO i = 1, 4 DO j = 1, 6 IF (data_out(i,j) .NE. dset_data(i, j)) THEN - WRITE(*, *) "dataset test error occured" - WRITE(*,*) "data read is not the same as the data writen" + WRITE(*, *) "dataset test error occurred" + WRITE(*,*) "data read is not the same as the data written" END IF END DO END DO @@ -541,7 +541,7 @@ SUBROUTINE test_chunk_cache(cleanup, total_error) CALL H5Dclose_f(dsid, error) CALL H5Oopen_f(fid, "dset", dsid, error, dapl1) - ! Retrieve dapl from dataset, verfiy cache values are the same as on dapl1 + ! Retrieve dapl from dataset, verify cache values are the same as on dapl1 ! ! Note we rely on the knowledge that H5Pget_chunk_cache retrieves these ! values directly from the dataset structure, and not from a copy of the @@ -563,7 +563,7 @@ SUBROUTINE test_chunk_cache(cleanup, total_error) CALL H5Oopen_f(fid, "dset", dsid, error) CALL check("H5Oopen_f", error, total_error) - ! Retrieve dapl from dataset, verfiy cache values are the same as on fapl_local + ! Retrieve dapl from dataset, verify cache values are the same as on fapl_local CALL H5Dget_access_plist_f(dsid, dapl2, error) CALL check("H5Dget_access_plist_f", error, total_error) @@ -575,7 +575,7 @@ SUBROUTINE test_chunk_cache(cleanup, total_error) CALL H5Pclose_f(dapl2,error) CALL check("H5Pclose_f", error, total_error) - ! Similary, test use of H5Dcreate2 with H5P_DEFAULT + ! Similarly, test use of H5Dcreate2 with H5P_DEFAULT CALL H5Dclose_f(dsid, error) CALL check("H5Dclose_f", error, total_error) diff --git a/fortran/test/tH5R.F90 b/fortran/test/tH5R.F90 index 5144d83..4e62b20 100644 --- a/fortran/test/tH5R.F90 +++ b/fortran/test/tH5R.F90 @@ -142,7 +142,7 @@ SUBROUTINE refobjtest(cleanup, total_error) CALL check("h5gclose_f",error,total_error) ! - ! Craete references to two groups, integer dataset and shared datatype + ! Create references to two groups, integer dataset and shared datatype ! and write it to the dataset in the file ! CALL h5rcreate_f(file_id, groupname1, ref(1), error) diff --git a/fortran/test/tH5S.F90 b/fortran/test/tH5S.F90 index 08f0b59..302db51 100644 --- a/fortran/test/tH5S.F90 +++ b/fortran/test/tH5S.F90 @@ -151,7 +151,7 @@ CONTAINS CALL h5sget_simple_extent_dims_f(space2_id, dimsout, maxdimsout, error) CALL check("h5sget_simple_extent_dims_f", error, total_error) IF ((dimsout(1) .NE. dims1(1)) .OR. (dimsout(2) .NE. dims1(2)) ) THEN - write(*,*)"error occured, copied dims not same" + write(*,*)"error occurred, copied dims not same" END IF ! @@ -159,14 +159,14 @@ CONTAINS ! CALL h5sget_simple_extent_ndims_f(space2_id, rank2, error) CALL check("h5sget_simple_extent_ndims_f", error, total_error) - IF (rank2 .NE. rank1) write(*,*)"error occured, copied ranks not same" + IF (rank2 .NE. rank1) write(*,*)"error occurred, copied ranks not same" ! !get the copied space's number of elements. ! CALL h5sget_simple_extent_npoints_f(space2_id, npoints, error) CALL check("h5sget_simple_extent_npoints_f", error, total_error) - IF (npoints .NE. 24) write(*,*)"error occured, number of elements not correct" + IF (npoints .NE. 24) write(*,*)"error occurred, number of elements not correct" ! @@ -194,7 +194,7 @@ CONTAINS CALL h5sget_simple_extent_dims_f(space2_id, dimsout, maxdimsout, error) CALL check("h5sget_simple_extent_dims_f", error, total_error) IF ((dimsout(1) .NE. dims2(1)) .OR. (dimsout(2) .NE. dims2(2)) ) THEN - write(*,*)"error occured, copied dims not same" + write(*,*)"error occurred, copied dims not same" END IF ! @@ -235,8 +235,8 @@ CONTAINS do i = 1, 4 do j = 1, 6 IF (data1_out(i,j) .NE. data1_in(i, j)) THEN - write(*, *) "dataset test error occured" - write(*,*) "data read is not the same as the data writen" + write(*, *) "dataset test error occurred" + write(*,*) "data read is not the same as the data written" END IF end do end do @@ -256,8 +256,8 @@ CONTAINS do i = 1, 6 do j = 1, 6 IF (data2_out(i,j) .NE. data2_in(i, j)) THEN - write(*, *) "dataset test error occured" - write(*,*) "data read is not the same as the data writen" + write(*, *) "dataset test error occurred" + write(*,*) "data read is not the same as the data written" END IF end do end do diff --git a/fortran/test/tH5Sselect.F90 b/fortran/test/tH5Sselect.F90 index 178ac32..41cd16f 100644 --- a/fortran/test/tH5Sselect.F90 +++ b/fortran/test/tH5Sselect.F90 @@ -149,7 +149,7 @@ CONTAINS ! ! - !Initialize FORTRAN predifined datatypes + !Initialize FORTRAN predefined datatypes ! ! CALL h5init_types_f(error) ! CALL check("h5init_types_f", error, total_error) @@ -430,7 +430,7 @@ CONTAINS end do ! - !Initialize FORTRAN predifined datatypes + !Initialize FORTRAN predefined datatypes ! ! CALL h5init_types_f(error) ! CALL check("h5init_types_f", error, total_error) @@ -912,7 +912,7 @@ CONTAINS ! CALL h5sget_select_hyper_nblocks_f(dataspace, num_blocks, error) CALL check("h5sget_select_hyper_nblocks_f", error, total_error) - IF (num_blocks .NE. 4) write (*,*) "error occured with num_blocks" + IF (num_blocks .NE. 4) write (*,*) "error occurred with num_blocks" !write(*,*) num_blocks !result of num_blocks is 4 @@ -945,11 +945,11 @@ CONTAINS CALL h5sget_select_bounds_f(dataspace, startout, endout, error) CALL check("h5sget_select_bounds_f", error, total_error) IF ( (startout(1) .ne. 1) .or. (startout(2) .ne. 1) ) THEN - write(*,*) "error occured to select_bounds's start position" + write(*,*) "error occurred to select_bounds's start position" END IF IF ( (endout(1) .ne. 5) .or. (endout(2) .ne. 5) ) THEN - write(*,*) "error occured to select_bounds's end position" + write(*,*) "error occurred to select_bounds's end position" END IF !write(*,*) (startout(i), i = 1, RANK) !result of startout is 0, 0 @@ -978,7 +978,7 @@ CONTAINS ! CALL h5sget_select_elem_npoints_f(dataspace, num_points, error) CALL check("h5sget_select_elem_npoints_f", error, total_error) - IF (num_points .NE. 10) write(*,*) "error occured with num_points" + IF (num_points .NE. 10) write(*,*) "error occurred with num_points" !write(*,*) num_points ! result of num_points is 10 diff --git a/fortran/test/tH5T.F90 b/fortran/test/tH5T.F90 index 8b10136..d24ac89 100644 --- a/fortran/test/tH5T.F90 +++ b/fortran/test/tH5T.F90 @@ -72,7 +72,7 @@ CONTAINS INTEGER(HID_T) :: dt4_id ! Memory datatype identifier (for real field) INTEGER(HID_T) :: dt5_id ! Memory datatype identifier INTEGER(HID_T) :: membtype_id ! Datatype identifier - INTEGER(HID_T) :: plist_id ! Dataset trasfer property + INTEGER(HID_T) :: plist_id ! Dataset transfer property INTEGER(HSIZE_T), DIMENSION(1) :: dims = (/dimsize/) ! Dataset dimensions @@ -98,7 +98,7 @@ CONTAINS INTEGER :: class ! Datatype class INTEGER :: num_members ! Number of members in the compound datatype CHARACTER(LEN=256) :: member_name - INTEGER :: len ! Lenght of the name of the compound datatype member + INTEGER :: len ! Length of the name of the compound datatype member INTEGER :: member_index ! index of the field INTEGER(HSIZE_T), DIMENSION(3) :: array_dims=(/2,3,4/) INTEGER :: array_dims_range = 3 @@ -219,9 +219,9 @@ CONTAINS CALL h5tcreate_f(H5T_COMPOUND_F, type_size, dtype_id, error) CALL check("h5tcreate_f", error, total_error) ! - ! Insert memebers + ! Insert members ! - ! CHARACTER*2 memeber + ! CHARACTER*2 member ! offset = 0 CALL h5tinsert_f(dtype_id, "char_field", offset, dt5_id, error) @@ -229,13 +229,13 @@ CONTAINS ! ! INTEGER member ! - offset = offset + type_sizec ! Offset of the second memeber is 2 + offset = offset + type_sizec ! Offset of the second member is 2 CALL h5tinsert_f(dtype_id, "integer_field", offset, H5T_NATIVE_INTEGER, error) CALL check("h5tinsert_f", error, total_error) ! ! DOUBLE PRECISION member ! - offset = offset + type_sizei ! Offset of the third memeber is 6 + offset = offset + type_sizei ! Offset of the third member is 6 CALL h5tinsert_f(dtype_id, "double_field", offset, H5T_NATIVE_DOUBLE, error) CALL check("h5tinsert_f", error, total_error) ! @@ -416,7 +416,7 @@ CONTAINS CALL h5tequal_f(membtype_id, H5T_NATIVE_INTEGER, flag, error) CALL check("h5tequal_f", error, total_error) if(.not. flag) then - write(*,*) "Wrong member type returned for integer memebr" + write(*,*) "Wrong member type returned for integer member" total_error = total_error + 1 endif CALL h5tget_member_class_f(dtype_id, i-1, class, error) @@ -435,7 +435,7 @@ CONTAINS CALL h5tequal_f(membtype_id, H5T_NATIVE_DOUBLE, flag, error) CALL check("h5tequal_f", error, total_error) if(.not. flag) then - write(*,*) "Wrong member type returned for double precision memebr" + write(*,*) "Wrong member type returned for double precision member" total_error = total_error + 1 endif CALL h5tget_member_class_f(dtype_id, i-1, class, error) @@ -454,7 +454,7 @@ CONTAINS CALL h5tequal_f(membtype_id, H5T_NATIVE_REAL, flag, error) CALL check("h5tequal_f", error, total_error) if(.not. flag) then - write(*,*) "Wrong member type returned for real memebr" + write(*,*) "Wrong member type returned for real member" total_error = total_error + 1 endif CALL h5tget_member_class_f(dtype_id, i-1, class, error) diff --git a/fortran/test/tH5VL.F90 b/fortran/test/tH5VL.F90 index 2269fec..eb0470c 100644 --- a/fortran/test/tH5VL.F90 +++ b/fortran/test/tH5VL.F90 @@ -147,7 +147,7 @@ CONTAINS CALL check("h5dvlen_get_max_len_f", error, total_error) if(max_len .ne. data_dims(1)) then total_error = total_error + 1 - write(*,*) "Wrong number of elemets returned by h5dvlen_get_max_len_f" + write(*,*) "Wrong number of elements returned by h5dvlen_get_max_len_f" endif ! ! Read the dataset. @@ -317,7 +317,7 @@ CONTAINS CALL check("h5dvlen_get_max_len_f", error, total_error) if(max_len .ne. data_dims(1)) then total_error = total_error + 1 - write(*,*) "Wrong number of elemets returned by h5dvlen_get_max_len_f" + write(*,*) "Wrong number of elements returned by h5dvlen_get_max_len_f" endif ! ! Read the dataset. diff --git a/fortran/test/tH5Z.F90 b/fortran/test/tH5Z.F90 index 8c39fea..799067a 100644 --- a/fortran/test/tH5Z.F90 +++ b/fortran/test/tH5Z.F90 @@ -374,7 +374,7 @@ CONTAINS do i = 1, N do j = 1, M IF (data_out(i,j) .NE. dset_data(i, j)) THEN - write(*, *) "dataset test error occured" + write(*, *) "dataset test error occurred" write(*,*) "data read is not the same as the data written" num_errors = num_errors + 1 IF (num_errors .GE. 512) THEN diff --git a/hl/fortran/src/H5DSff.F90 b/hl/fortran/src/H5DSff.F90 index b241e9a..bbd9918 100644 --- a/hl/fortran/src/H5DSff.F90 +++ b/hl/fortran/src/H5DSff.F90 @@ -216,7 +216,7 @@ CONTAINS END SUBROUTINE H5DSis_attached_f ! -! H5DSiterate_scales: Impliment in F2003 +! H5DSiterate_scales: Implement in F2003 ! !------------------------------------------------------------------------- diff --git a/hl/fortran/src/H5HL_buildiface.F90 b/hl/fortran/src/H5HL_buildiface.F90 index 4f34575..ca66ebf 100644 --- a/hl/fortran/src/H5HL_buildiface.F90 +++ b/hl/fortran/src/H5HL_buildiface.F90 @@ -14,7 +14,7 @@ ! ! NOTES ! This program uses the Fortran 2008 intrinsic function STORAGE_SIZE or SIZEOF -! depending on availablity.It generates code that makes use of +! depending on availability.It generates code that makes use of ! STORAGE_SIZE/SIZEOF in H5fortran_detect.f90. STORAGE_SIZE is standard ! compliant and should always be chosen over SIZEOF. ! diff --git a/hl/fortran/src/H5LTff.F90 b/hl/fortran/src/H5LTff.F90 index ba4b770..a4ab247 100644 --- a/hl/fortran/src/H5LTff.F90 +++ b/hl/fortran/src/H5LTff.F90 @@ -88,7 +88,7 @@ MODULE H5LT_CONST TYPE(C_PTR), VALUE :: buf ! data buffer CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(in) :: dtype ! flag indicating the datatype of the ! the buffer: - ! R=Real, D=DOUBLE, I=Interger, C=Character + ! R=Real, D=DOUBLE, I=Integer, C=Character INTEGER(size_t) :: SizeOf_buf ! Sizeof the buf datatype END FUNCTION h5ltset_attribute_c END INTERFACE @@ -107,7 +107,7 @@ MODULE H5LT_CONST TYPE(C_PTR), VALUE :: buf ! data buffer CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(in) :: dtype ! flag indicating the datatype of the ! the buffer: - ! R=Real, D=DOUBLE, I=Interger + ! R=Real, D=DOUBLE, I=Integer INTEGER(size_t), INTENT(in) :: SizeOf_buf ! Sizeof the buf data type END FUNCTION h5ltget_attribute_c END INTERFACE diff --git a/hl/fortran/src/H5TBfc.c b/hl/fortran/src/H5TBfc.c index 23e3377..91c420b 100644 --- a/hl/fortran/src/H5TBfc.c +++ b/hl/fortran/src/H5TBfc.c @@ -83,7 +83,7 @@ h5tbmake_table_c(size_t_f *namelen1, _fcd name1, hid_t_f *loc_id, size_t_f *name (tmp = (char *)HD5f2cstring(field_names, (size_t) * (max_char_size_field_names) * (size_t)num_elem))) HGOTO_DONE(FAIL) /* - * move data from temorary buffer + * move data from temporary buffer */ tmp_p = tmp; for (i = 0; i < num_elem; i++) { @@ -188,7 +188,7 @@ h5tbmake_table_ptr_c(size_t_f *namelen1, _fcd name1, hid_t_f *loc_id, size_t_f * (tmp = (char *)HD5f2cstring(field_names, (size_t) * (max_char_size_field_names) * (size_t)num_elem))) HGOTO_DONE(FAIL) /* - * move data from temorary buffer + * move data from temporary buffer */ tmp_p = tmp; for (i = 0; i < num_elem; i++) { diff --git a/hl/fortran/src/H5TBff.F90 b/hl/fortran/src/H5TBff.F90 index 35a88b8..82f34a8 100644 --- a/hl/fortran/src/H5TBff.F90 +++ b/hl/fortran/src/H5TBff.F90 @@ -961,7 +961,7 @@ CONTAINS INTEGER(size_t), DIMENSION(1:nfields), INTENT(inout) :: field_offsets ! field offsets INTEGER(size_t), INTENT(inout):: type_size ! type size INTEGER(size_t) :: namelen ! name length - INTEGER(size_t) :: maxlen ! maxiumum length of input field names + INTEGER(size_t) :: maxlen ! maximum length of input field names INTEGER(size_t), DIMENSION(1:nfields) :: namelen2 ! name lengths INTEGER(size_t) :: c_maxlen_out ! maximum character length of a field array element END FUNCTION h5tbget_field_info_c diff --git a/hl/fortran/test/tsttable.F90 b/hl/fortran/test/tsttable.F90 index a77068c..e7bd88e 100644 --- a/hl/fortran/test/tsttable.F90 +++ b/hl/fortran/test/tsttable.F90 @@ -172,11 +172,11 @@ SUBROUTINE test_table1() ! offset = 0 field_offset(1) = offset - offset = offset + type_sizec ! Offset of the second memeber is 2 + offset = offset + type_sizec ! Offset of the second member is 2 field_offset(2) = offset - offset = offset + type_sizei ! Offset of the second memeber is 6 + offset = offset + type_sizei ! Offset of the second member is 6 field_offset(3) = offset - offset = offset + type_sized ! Offset of the second memeber is 14 + offset = offset + type_sized ! Offset of the second member is 14 field_offset(4) = offset !------------------------------------------------------------------------- @@ -571,7 +571,7 @@ SUBROUTINE test_table2() INTEGER(HSIZE_T), PARAMETER :: nrecords = 8 ! nrecords CHARACTER(len=8), PARAMETER :: filename = "f2tab.h5" ! File name - CHARACTER(LEN=5), PARAMETER :: table_name = "tabel" ! table name + CHARACTER(LEN=5), PARAMETER :: table_name = "table" ! table name CHARACTER(LEN=10), PARAMETER :: table_name_fill = "tabel_fill" ! table name ! Define field information -- cgit v0.12