MAN page from Mandrake Other XITE-3.3-3.i386.rpm
UTL_MALLOC
Section: C Library Functions (3)
Updated: 16 Mar 1998
Index
NAME
utl_malloc, Mmatrix_3d, Fmatrix_3d, Mmatrix_2d, Fmatrix_2d,Mmatrix_1d, Fmatrix_1d - allocates memory for various purposes
SYNTAX
#include <
xite/utl_malloc.h>
void *Mmatrix_1d( int i_first, int i_last,
int i_element_size, int i_clear );
void *Mmatrix_2d( int i_row_min, int i_row_max,
int i_col_min, int i_col_max,
int i_element_size, int i_clear );
void *Mmatrix_3d( int i_x_min, int i_x_max,
int i_y_min, int i_y_max, int i_z_min,
int i_z_max, int i_element_size,
int i_clear );
void *Fmatrix_1d( char* array );
void *Fmatrix_2d( char* i_matrix,
char* i_rows );
void *Fmatrix_3d( char* i_cube, char* i_matrix,
char* i_rows );
DESCRIPTION
These are various memory (de)allocation routines, all of themusing malloc (or calloc).
element_sizeis the size of the elements tobe allocated; i.e sizeof(int) for integers.
clearis one if thearray or matrix is to be filled by zeroes.
Mmatrix_1d returns a pointer to an array of (last - start + 1) elements.After the call
a = Mmatrix_1d(1,4,sizeof(int),1)
a[1] will be the first integer element of the array, a[4] will be thelast. All elements will be initialized to 0.
Mmatrix_2d will return a pointer to a two-dimensionalrectangular matrix allocatedin one chunk of memory. row_startand row_lastindicates first and lastelement of the rows.
Mmatrix_3d will return a pointer to a three-dimensional rectangular cubeallocated in one chunk of memory. x_start,x_last,y_start,y_last,z_startand z_lastgives the dimension of the cube.
Fmatrix_1d frees the memory allocated by Mmatrix_1d. The adress of thefirst dataelement must be supplied.
Fmatrix_2d frees the memory a||ocated by Mmatrix_2d. Parametersare adress of first matrix element, and adress of first row. Seethe example section for usage.
Fmatrix_3d frees the memory allocated by Mmatrix_3d. Parameters are adressof first cube element, adress of first matrix element, and adress of firstrow.
RETURN VALUE
A suitable pointer is returned. If no storagewas available, or if routine deallocates memory, returns NULL.All Fmatrix routines return NULL.
EXAMPLES
double **a;
Allocte room for a [0..2][0..8] double
precision matrix
a = Mmatrix_2d(0,2,0,8,sizeof(double),1);
Free a.
a = Fmatrix_2d( &a[0][0], &a[0]);
LINKING
cc progname.c -lutl
RESTRICTIONS
Assumes all pointers have the same size (ok on decstationsand suns).
HINTS
Always use row_start and col_start = 0: It will save you problems inthe long run. If you insist on offsets, remember to use
- array[row_start, col_start] if the address of the first element is needed.
BUGS
Compilers and lint might complain about mixing of data-types. Justignore them.
AUTHOR
gutorm hogasen, NCC
SEE ALSO
malloc(3),
free(3),
calloc(3)
DATE
Last update 7/1/91
FILE
$Id: utl_malloc.c,v 1.16 1995/08/23 14:58:49 svein Exp $
Index
- NAME
- SYNTAX
- DESCRIPTION
- RETURN VALUE
- EXAMPLES
- LINKING
- RESTRICTIONS
- HINTS
- BUGS
- AUTHOR
- SEE ALSO
- DATE
- FILE
This document was created byman2html,using the manual pages.