ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/atheme_memory.h
Revision: 1.4
Committed: Tue Aug 28 17:12:24 2007 UTC (16 years, 8 months ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +1 -1 lines
State: FILE REMOVED
Log Message:
removed old files

File Contents

# Content
1 /*
2 * Copyright © 2005 Atheme Development Group
3 * Rights to this code are as documented in doc/pod/license.pod.
4 *
5 * Memory stuff.
6 *
7 * $Id: atheme_memory.h,v 1.3 2007-07-25 00:03:21 pippijn Exp $
8 */
9
10 #ifndef __CLAROBASEMEMORY
11 #define __CLAROBASEMEMORY
12
13 E void *smalloc (size_t size);
14 E void *scalloc (size_t elsize, size_t els);
15 E void *srealloc (void *oldptr, size_t newsize);
16 E char *sstrdup (const char *s);
17 E char *sstrndup (const char *s, int len);
18
19 // simple garbage collection for smalloc'ed blocks
20 struct gc
21 {
22 static void insert (void *ptr)
23 {
24 mortals.push_back (ptr);
25 }
26
27 static void cleanup ()
28 {
29 while (!mortals.empty ())
30 {
31 free (mortals.back ());
32 mortals.pop_back ();
33 }
34 }
35
36 private:
37 static std::vector<void *> mortals;
38 };
39
40 #endif