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