Revision 18c8241a lib/resource.h

View differences:

lib/resource.h
14 14
/* Resource */
15 15

  
16 16
typedef struct resource {
17
	node n;				/* Inside resource pool */
18
	struct resclass *class;		/* Resource class */
17
  node n;				/* Inside resource pool */
18
  struct resclass *class;		/* Resource class */
19 19
} resource;
20 20

  
21 21
/* Resource class */
22 22

  
23 23
struct resclass {
24
	char *name;			/* Resource class name */
25
	unsigned size;			/* Standard size of single resource */
26
	void (*free)(resource *);	/* Freeing function */
27
	void (*dump)(resource *);	/* Dump to debug output */
24
  char *name;				/* Resource class name */
25
  unsigned size;			/* Standard size of single resource */
26
  void (*free)(resource *);		/* Freeing function */
27
  void (*dump)(resource *);		/* Dump to debug output */
28 28
};
29 29

  
30 30
/* Generic resource manipulation */
31 31

  
32 32
typedef struct pool pool;
33 33

  
34
void resource_init(void);
34 35
pool *rp_new(pool *);			/* Create new pool */
35
void rp_init(pool *);			/* Initialize static pool */
36
void rp_empty(pool *);			/* Free everything in the pool */
36
void rp_free(pool *);			/* Free everything in the pool */
37 37
void rfree(void *);			/* Free single resource */
38 38
void rdump(void *);			/* Dump to debug output */
39 39

  
40
void ralloc(pool *, struct resclass *);
40
void *ralloc(pool *, struct resclass *);
41

  
42
extern pool root_pool;
41 43

  
42 44
/* Normal memory blocks */
43 45

  
44 46
void *mb_alloc(pool *, unsigned size);
45
void *mb_free(void *);
47
void mb_free(void *);
46 48

  
47 49
/* Memory pools with linear allocation */
48 50

  
49 51
typedef struct mempool mempool;
50 52

  
51 53
mempool *mp_new(pool *, unsigned blk);
52
void mp_trim(pool *);				/* Free unused memory */
53 54
void *mp_alloc(mempool *, unsigned size);	/* Aligned */
54 55
void *mp_allocu(mempool *, unsigned size);	/* Unaligned */
55 56
void *mp_allocz(mempool *, unsigned size);	/* With clear */

Also available in: Unified diff