source: vis_dev/glu-2.3/src/mem/mem.3 @ 23

Last change on this file since 23 was 13, checked in by cecile, 13 years ago

library glu 2.3

File size: 3.8 KB
RevLine 
[13]1.\" Storage management library man page
2.TH MEM 3 "16 November 1993"
3.SH NAME
4mem \- a memory management package
5.SH SYNOPSIS
6.B #include <memuser.h>
7.SH DESCRIPTION
8The
9.B libmem
10library provides a set of routines for allocating storage.  Programs
11designed to be used with the library should use the
12.B -lmem
13options to
14.B cc
15when linking.
16.SH "LIST OF FUNCTIONS"
17.nf
18.ta 3in
19\fIName\fP      \fIFunction\fP
20mem_get_block   Allocate a block of memory
21mem_free_block  Free a block of memory
22mem_resize_block        Resize a block of memory
23mem_copy        Copy a block of memory
24mem_zero        Initialize a block of memory to all zeros
25mem_allocation  Get total memory allocation
26mem_new_rec_mgr Create a record manager
27mem_free_rec_mgr        Destroy a record manager
28mem_new_rec     Get a record from a record manager
29mem_free_rec    Return a record to a record manager
30.fi
31.SH "OVERVIEW"
32The library includes routines for handling blocks of memory and for
33dealing with fixed size records.  The block manipulation routines use
34a binary buddy scheme, so fragmentation generally is not a problem.
35The record manager routines are designed for handling many small,
36fixed size records.  There is essentially no storage overhead when
37using these routines, and allocation and deallocation are particularly
38fast.
39.SH "DETAILED DESCRIPTION"
40.B pointer
41.br
42.B mem_get_block(size)
43.br
44.B long size;
45.in +4
46Allocate a block of storage
47.B size
48bytes long.  The type
49.B pointer
50is defined to be either a character pointer or a void pointer,
51depending on whether the C compiler is ANSI-standard.
52.LP
53.B void
54.br
55.B mem_free_block(p)
56.br
57.B pointer p;
58.in +4
59Free the block of storage pointed to by \fBp\fR.
60.LP
61.B pointer
62.br
63.B mem_resize_block(p, size)
64.br
65.B pointer p;
66.br
67.B long size;
68.in +4
69Try to resize the block of memory pointed to by
70.B p
71to be
72.B size
73bytes long.  If this is not possible, a new block is allocated and the
74contents of the old block are copied.  A pointer to the expanded block
75is returned.
76.LP
77.B void
78.br
79.B mem_copy(p, q, size)
80.br
81.B pointer p;
82.br
83.B pointer q;
84.br
85.B long size;
86.in +4
87Copy
88.B size
89bytes from the location given by
90.B q
91to the location give by \fBp\fR.
92.LP
93.LP
94.B void
95.br
96.B mem_zero(p, size)
97.br
98.B pointer p;
99.br
100.B long size;
101.in +4
102Fill
103.B size
104bytes at the location given by
105.B p
106with zero.
107.LP
108.B long
109.br
110.B mem_allocation()
111.in +4
112Returns the total memory allocation in bytes.
113.LP
114.B rec_mgr
115.br
116.B mem_new_rec_mgr(size)
117.br
118.B int size;
119.in +4
120Returns a new record manager for handling record of
121.B size
122bytes.  The size is limited to approximately 4K, but is really
123intended to be smaller.
124.LP
125.B void
126.br
127.B mem_free_rec_mgr(m)
128.br
129.B rec_mgr m;
130.in +4
131Free the record manager given by
132.B m
133and all of its associated storage.
134.LP
135.B pointer
136.br
137.B mem_new_rec(m)
138.br
139.B rec_mgr m;
140.in +4
141Return a pointer to a new record.
142.LP
143.B void
144.br
145.B mem_free_rec(m, p)
146.br
147.B rec_mgr m;
148.br
149.B pointer p;
150.in +4
151Return the record pointed to by
152.B p
153to the record manager \fBm\fR.
154.SH "PORTABILITY NOTES"
155The library is fairly UNIX specific; it calls
156.B sbrk
157directly.  If you don't have something similar, you may have to
158rewrite parts of it.  The storage management routines need to be able
159to move and clear blocks of memory whose size is given by a long.  You
160may have to fiddle with these, especially if you have a machine where
161int and long are different.  If you encounter portability problems,
162let me know; maybe the next release will be able to accommodate your
163machine.  For non-UNIX people, or if you are using malloc elsewhere
164and it is unhappy about other routines calling sbrk, you can try
165defining the symbol USE_MALLOC_FREE in memint.h.  It turns calls to
166the memory management library routines into calls to malloc, free, and
167cousins.  This has not been tested extensively.
168.SH BUGS
169It's a feature.
170.SH AUTHOR
171David E. Long
172.br
173long@research.att.com
174
Note: See TracBrowser for help on using the repository browser.