]> git.imager.perl.org - imager.git/blob - imio.h
more stuff TODO
[imager.git] / imio.h
1 #ifndef IMAGER_IMIO_H_
2 #define IMAGER_IMIO_H_
3 #include <stdio.h>
4 #include <sys/stat.h>
5
6 #include "log.h"
7
8
9 /* #define MALLOC_DEBUG */
10
11 #ifdef IMAGER_DEBUG_MALLOC
12
13 #define mymalloc(x) (mymalloc_file_line((x), __FILE__, __LINE__))
14 #define myrealloc(x,y) (myrealloc_file_line((x),(y), __FILE__, __LINE__))
15 #define myfree(x) (myfree_file_line((x), __FILE__, __LINE__))
16
17 void  malloc_state       (void);
18 void* mymalloc_file_line (size_t size, char* file, int line);
19 void  myfree_file_line   (void *p, char*file, int line);
20 void* myrealloc_file_line(void *p, size_t newsize, char* file,int line);
21 void* mymalloc_comm      (int size, char *comm);
22 void  bndcheck_all       (void);
23
24 #else
25
26 #define malloc_comm(a,b) (mymalloc(a))
27 void  malloc_state(void);
28 void* mymalloc(int size);
29 void  myfree(void *p);
30 void* myrealloc(void *p, size_t newsize);
31
32 #endif /* IMAGER_MALLOC_DEBUG */
33
34
35
36 typedef struct i_mempool {
37   void **p;
38   unsigned int alloc;
39   unsigned int used;
40 } i_mempool;
41
42 void  i_mempool_init(i_mempool *mp);
43 void  i_mempool_extend(i_mempool *mp);
44 void *i_mempool_alloc(i_mempool *mp, size_t size);
45 void  i_mempool_destroy(i_mempool *mp);
46
47
48
49 #ifdef _MSC_VER
50 #undef min
51 #undef max
52 #endif
53
54 extern unsigned long i_utf8_advance(char const **p, int *len);
55
56 /* XXX Shouldn't these go away? */
57
58 int i_min(int a,int b);
59 int i_max(int x,int y);
60
61 #endif