Mdalloc.C 1.0

Operating systemsOS : Windows / Linux / BSD / Solaris
Program licensingScript Licensing : Freeware
CreatedCreated : Apr 30, 2007
Size downloadDownloads : 2
Program licensing
Thank you for voting...

mdalloc - a multi dimensional array allocator<br ...

mdalloc - a multi dimensional array allocator
mdfree - a companion function to mdalloc for freeing storage
synopsis:
void *mdalloc(int ndim, int width, . . . );
where: ndim: number of array dimensions
width: size of elements in array
variable args are dimensions of array
returns: n-way indirect pointer to allocated storage or NULL if insufficient storage
void mdfree(void *p, ndim);
where: p: pointer to storage obtained by mdalloc
ndim: number of dimensions used in mdalloc
example:
int ***tip;
tip = mdalloc(3, sizeof(int), 2, 3, 4);
tip will be a triple indirect pointer to a 3 dimensional array
tip[0][0][0] refers to the first int in a contiguous area of
storage that is 2*3*4*sizeof(int) bytes long
tip[0][0] is the address of the first int
memset can be used to initialize array elements as follows:
memset(tip[0][0], 0, 2*3*4*sizeof(int));
mdfree is used to free storage obtained with mdalloc: mdfree(tip, 3)
notes:
- must be compiled with appropriate memory model
- memory is allocated for each dimension for indirect pointers
eg. 3x4x5 array of longs (assuming 4 byte longs, small mem model)
p = mdalloc(3, sizeof(long), 3, 4, 5) - bytes
3 pointers allocated for 1st dimension - 6
3x4 pointers allocated for 2nd dimension - 24
3x4x5 longs allocated for array elements - 240
total of 270 bytes allocated
- if insufficient memory, nothing will be allocated.
ie. intermediate pointer arrays that were successfully
allocated will be freed.
- the intent of mdalloc is to facilitate dynamic array creation,
it will use more memory than statically declared arrays, and the required dereferencing will be slower than the use of statically declared arrays.
- this function assumes that sizeof(char) == 1.

Mdalloc.C 1.0 scripting tags: pointer, mdalloc snippets, allocated, mdallocc, array snippets, ndim, array allocte, tip, storage. What is new in Mdalloc.C 1.0 software script? - Unable to find Mdalloc.C 1.0 news. What is improvements are expecting? Newly-made Mdalloc.C 1.1 will be downloaded from here. You may download directly. Please write the reviews of the Mdalloc.C. License limitations are unspecified.