.\" $Id: rdsalloc.3,v 1.1 2002/03/13 13:37:37 fred Exp $ .\" @(#)rdsalloc.1 1.11 93/08/18 ; Labo masi cao-vlsi .if t \{\ .XS \n% .ti 0.2i rdsalloc .XE .XS0 \n% .ti 0.2i rdsalloc .XE0 \} .TH RDSALLOC 3 "October 1, 1997" "ASIM/LIP6" "RDS PHYSICAL FUNCTIONS" .SH NAME rdsalloc \- memory allocation function .so jessie/alliance/alc_origin.1.en.gz .SH SYNOPSYS .nf .if n \{\ .ft B \} .if t \{\ .ft CR \} #include "rdsnnn.h" char \(**rdsalloc( Size, Heap ) unsigned int Size; char Heap; .ft R .fi .SH PARAMETER .TP 20 \fISize\fP memory size to allocate .TP \fIHeap\fP takes the values RDS_ALLOC_BLOCK or RDS_ALLOC_HEAP (two defined constants). .SH DESCRIPTION The \fIrdsalloc\fP function can do memory allocation by block or by heap. If the user wants to allocate by block, he sets the parameter Heap to the constant RDS_ALLOC_BLOCK else, he wants to allocate by heap so the parameter Heap is set to RDS_ALLOC_HEAP. If rdsalloc is used with the constant RDS_ALLOC_BLOCK then rdsalloc is used as standard language C function malloc(). If the user allocates by heap then : At the first allocation of the block of \fIsize\fP the parameter \'Size\', a heap of size multiple of the block Size is allocated. When another allocation of the same size is done then if the the heap isn't full then a pointer (of \fIsize\fP=\'Size\') is returned else a new heap is allocated and a pointer returned. Like this, the user does really one allocation (he has many pointers) to minimize fragmentation. Heap allocation is usefull if the user has to allocate many pointers of the same size (ex: rdsrec_list structure). .TP Note: Memory place allocated is set to NULL. .SH RETURN VALUE pointer to the allocated memory is returned. .SH ERRORS .if n \{\ .ft B \} .if t \{\ .ft CR \} "Rds202: rdsalloc error, can't continue !" .ft R .RS it's impossible to allocate the memory size desired. .SH EXAMPLE .ta 3n 6n 9n 12n 15n 18n 21n .nf .if n \{\ .ft B \} .if t \{\ .ft CR \} #include "rdsnnn.h" main() { rdsrec_list \(**Rectangle; rdsfig_list \(**Figure; Rectangle = (rdsrec_list \(**) \fBrdsalloc\fP (sizeof(rdsrec_list \(**),RDS_ALLOC_HEAP); Figure = (rdsfig_list \(**) \fBrdsalloc\fP (sizeof(rdsfig_list \(**),RDS_ALLOC_BLOCK); } .ft R .fi .SH SEE ALSO .BR librds, .BR rdsfree .so jessie/alliance/alc_bug_report.1.en.gz