2 This file is part of the software library CADLIB written by Conrad Ziesler
3 Copyright 2003, Conrad Ziesler, all rights reserved.
5 *************************
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 /* memory.h, header for private memory allocation routines
28 #define MEMORY_CHUNKSIZE (1024*16)
29 #define MEMORY_THRESHOLD 16 /* a block is full if it within this size of full */
31 typedef struct memory_chain_st
33 struct memory_chain_st
*next
;
35 int qref
; /* we maintain an reference count */
36 char data
[MEMORY_CHUNKSIZE
];
39 #define MEMORY_MAGIC 0x35dfa315
41 typedef struct memory_other_st
43 struct memory_other_st
*next
;
46 typedef struct memory_head_st
48 memory_chain_t
*head
,*full
;
49 memory_other_t
*others
;
52 #define MEMORY_INIT { NULL, NULL, NULL }
55 void *memory_alloc(memory_t
*ma
, int size
);
56 void memory_free(memory_t
*ma
, void *vp
);
57 void memory_freeall(memory_t
*ma
);
58 void memory_init(memory_t
*ma
);