1RDSALLOC(3) RDS PHYSICAL FUNCTIONS RDSALLOC(3)
2
3
4
6 rdsalloc - memory allocation function
7
9 #include "rdsnnn.h"
10 char ∗rdsalloc( Size, Heap )
11 unsigned int Size;
12 char Heap;
13
15 Size memory size to allocate
16
17 Heap takes the values RDS_ALLOC_BLOCK or RDS_ALLOC_HEAP
18 (two defined constants).
19
21 The rdsalloc function can do memory allocation by block or by heap. If
22 the user wants to allocate by block, he sets the parameter Heap to the
23 constant RDS_ALLOC_BLOCK else, he wants to allocate by heap so the
24 parameter Heap is set to RDS_ALLOC_HEAP. If rdsalloc is used with the
25 constant RDS_ALLOC_BLOCK then rdsalloc is used as standard language C
26 function malloc(). If the user allocates by heap then : At the first
27 allocation of the block of size the parameter ´Size´, a heap of size
28 multiple of the block Size is allocated. When another allocation of the
29 same size is done then if the the heap isn't full then a pointer (of
30 size=´Size´) is returned else a new heap is allocated and a pointer
31 returned. Like this, the user does really one allocation (he has many
32 pointers) to minimize fragmentation. Heap allocation is useful if the
33 user has to allocate many pointers of the same size (ex: rdsrec_list
34 structure).
35
36 Note: Memory place allocated is set to NULL.
37
39 pointer to the allocated memory is returned.
40
42 "Rds202: rdsalloc error, can't continue !"
43 it's impossible to allocate the memory size desired.
44
46 #include "rdsnnn.h"
47 main()
48 {
49 rdsrec_list ∗Rectangle;
50 rdsfig_list ∗Figure;
51 Rectangle =
52 (rdsrec_list ∗) rdsalloc (sizeof(rdsrec_list ∗),RDS_ALLOC_HEAP);
53 Figure =
54 (rdsfig_list ∗) rdsalloc (sizeof(rdsfig_list ∗),RDS_ALLOC_BLOCK);
55 }
56
58 librds, rdsfree
59
60
61
62
63
64
65ASIM/LIP6 October 1, 1997 RDSALLOC(3)