#ifndef __MEMTOOLS_H__
#define __MEMTOOLS_H__

/******************************************************************************
* MEMTOOLS.H                                                                  *
*                                                                             *
* The header file for MEMTOOLS.C                                              *
*                                                                             *
* Once upon a time I stumbled across some C code to dynammically allocate     *
* arrays of arbitrary length and generic structure.  (Google search for       *
* "Dynamic Array Allocator" and "Richard Hogaboom").  I thought it was        *
* pretty cool and decided to modify it for ease-of-reading and easier         *
* calling.                                                                    *
*                                                                             *
* Inputs:                                                                     *
*                                                                             *
*     int   SIZE - Size of the basic data object.                             *
*                  This can usually be gotten via the sizeof() operator.      *
*                                                                             *
*     int   N    - Number of array dimensions.                                *
*                                                                             *
*     int*  DIMS - Vector of array dimensions (length N).                     *
*                                                                             *
*     char* FREE - Holder for pointer to raw memory space.                    *
*                  After calling the function, this will be the pointer to    *
*                  pass to free() when done with memory.                      *
*                                                                             *
* Return:                                                                     *
*                                                                             *
*     void* TENSOR - Pointer to allocated and ordered memory block.           *
*                    You'll need to recast to whatever data type fills it.    *
*                    Remember not to call free() on this returned pointer;    *
*                    that's what char* FREE is for.                           *
*                                                                             *
*                                                                             *
* Thanks and acknowledgements to Richard Hogaboom for original source code    *
* and for releasing the concept as freeware.                                  *
*                                                                             *
* James Holliday                                                              *
* University of California - Davis                                            *
*                                                                             *
******************************************************************************/

/* Allocate memory for N-d arrays (with element length = size) */
void* allocate(int size, int N, int* dim, char* free);

#endif
