/usr/include/volume_io/arrays.h is in libminc-dev 2.3.00-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | #ifndef VOL_IO_ARRAYS_H
#define VOL_IO_ARRAYS_H
/* ----------------------------------------------------------------------------
@COPYRIGHT :
Copyright 1993,1994,1995 David MacDonald,
McConnell Brain Imaging Centre,
Montreal Neurological Institute, McGill University.
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies. The author and McGill University
make no representations about the suitability of this
software for any purpose. It is provided "as is" without
express or implied warranty.
@VERSION : $Header: /private-cvsroot/minc/volume_io/Include/volume_io/arrays.h,v 1.13 2004-10-04 20:23:51 bert Exp $
---------------------------------------------------------------------------- */
/* ----------------------------- MNI Header -----------------------------------
@NAME : arrays.h
@INPUT :
@OUTPUT :
@RETURNS :
@DESCRIPTION: Macros for adding to and deleting from arrays.
@METHOD :
@GLOBALS :
@CALLS :
@CREATED : David MacDonald
@MODIFIED :
---------------------------------------------------------------------------- */
#include <volume_io/alloc.h>
#define DEFAULT_CHUNK_SIZE 100
/* ----------------------------- MNI Header -----------------------------------
@NAME : SET_ARRAY_SIZE
@INPUT : array
previous_n_elems
new_n_elems - desired new array size
chunk_size
@OUTPUT :
@RETURNS :
@DESCRIPTION: Sets the number of items allocated in the array to a multiple of
: chunk_size larger than new_n_elems
@METHOD :
@GLOBALS :
@CALLS :
@CREATED : David MacDonald
@MODIFIED :
---------------------------------------------------------------------------- */
#define SET_ARRAY_SIZE( array, previous_n_elems, new_n_elems, chunk_size ) \
set_array_size( (void **) (&(array)), sizeof(*(array)), \
(size_t) (previous_n_elems), \
(size_t) (new_n_elems), \
(size_t) (chunk_size) _ALLOC_SOURCE_LINE )
/* ----------------------------- MNI Header -----------------------------------
@NAME : ADD_ELEMENT_TO_ARRAY
@INPUT : array : the array to add to
: n_elems : current number of items in the array
: elem_to_add : the item to add
: chunk_size : the chunk_size for allocation
@OUTPUT :
@RETURNS :
@DESCRIPTION: Adds an element to the end of an array, and increments the n_elems
@METHOD :
@GLOBALS :
@CALLS :
@CREATED : David MacDonald
@MODIFIED :
---------------------------------------------------------------------------- */
#define ADD_ELEMENT_TO_ARRAY( array, n_elems, elem_to_add, chunk_size) \
{ \
SET_ARRAY_SIZE( array, n_elems, (n_elems)+1, chunk_size ); \
(array) [(n_elems)] = (elem_to_add); \
++(n_elems); \
}
/* ----------------------------- MNI Header -----------------------------------
@NAME : DELETE_ELEMENT_FROM_ARRAY
@INPUT : array : the array to add to
: n_elems : current number of items in the array
: index_to_remove : the index of the element to delete
: chunk_size : the chunk_size for allocation
@OUTPUT :
@RETURNS :
@DESCRIPTION: Deletes an element from an array, sliding down subsequent
: elements, and decrements the n_elems
@METHOD :
@GLOBALS :
@CALLS :
@CREATED : David MacDonald
@MODIFIED :
---------------------------------------------------------------------------- */
#define DELETE_ELEMENT_FROM_ARRAY( array, n_elems, index_to_remove, chunk_size ) \
{ \
(void) memmove( (void *) ((unsigned long) (array) + \
(unsigned long) (index_to_remove) * (unsigned long) sizeof(*(array))), \
(void *) ((unsigned long) (array) + \
((unsigned long) (index_to_remove)+1)* (unsigned long) sizeof(*(array))),\
((size_t) (n_elems) - (size_t) (index_to_remove) - 1) * sizeof(*(array)) );\
\
--(n_elems); \
\
SET_ARRAY_SIZE( array, (n_elems)+1, n_elems, chunk_size); \
}
/* ----------------------------- MNI Header -----------------------------------
@NAME : ADD_ELEMENT_TO_ARRAY_WITH_SIZE
@INPUT : array
: n_alloced
: n_elems
: elem_to_add
: chunk_size
@OUTPUT :
@RETURNS :
@DESCRIPTION: Adds an element to an array where a separate n_allocated and
: n_elems is maintained. n_allocated will always be greater than
: or equal to n_elems. This routine is useful so that you don't
: have to call SET_ARRAY_SIZE everytime you remove an element,
: as in done in DELETE_ELEMENT_FROM_ARRAY
@METHOD :
@GLOBALS :
@CALLS :
@CREATED : David MacDonald
@MODIFIED :
---------------------------------------------------------------------------- */
#define ADD_ELEMENT_TO_ARRAY_WITH_SIZE( array, n_alloced, n_elems, elem_to_add, chunk_size ) \
{ \
if( (n_elems) >= (n_alloced) ) \
{ \
SET_ARRAY_SIZE( array, n_alloced, (n_elems) + 1, chunk_size );\
(n_alloced) = (n_elems)+1; \
} \
(array) [(n_elems)] = (elem_to_add); \
++(n_elems); \
}
#endif /* VOL_IO_ARRAYS_H */
|