1 /* 2 * pools.h 3 * 4 * MathMap 5 * 6 * Copyright (C) 2002-2004 Mark Probst 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 */ 22 23 #ifndef __POOLS_H__ 24 #define __POOLS_H__ 25 26 #include <stdlib.h> 27 28 /* these settings allow a pools to grow to up to 16 GB (last pool 8GB) */ 29 #define GRANULARITY sizeof(long) 30 #define FIRST_POOL_SIZE ((size_t)2048) 31 #define NUM_POOLS 20 32 33 typedef struct 34 { 35 int active_pool; 36 size_t fill_ptr; 37 long *pools[NUM_POOLS]; 38 } pools_t; 39 40 void init_pools (pools_t *pools); 41 void reset_pools (pools_t *pools); 42 void free_pools (pools_t *pools); 43 44 void* pools_alloc (pools_t *pools, size_t size); 45 46 #endif 47