summaryrefslogtreecommitdiffstats
path: root/include/linux/simp.h
blob: bf838f8153d9d5aec1c746b7c9903a50396e0f6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * include/linux/simp.h  -- simple allocator for cached objects
 *
 * This is meant as a faster and simpler (not full-featured) replacement
 * for SLAB, thus the name "simp" :-)
 *
 * (C) 1997 Thomas Schoebel-Theuer
 */

#ifndef SIMP_H
#define SIMP_H

/* used for constructors / destructors */
typedef void (*structor)(void *);

/* create an object cache */
/* positive clearable_offset means the next two pointers at that offset
 * can be internally used for freelist pointers when the object is
 * deallocated / not in use;
 * if there is no space inside the element that can be reused for
 * this purpose, supply -1. Using positive offsets is essential for
 * saving space with very small-sized objects.
 *
 * Note for big-sized objects in the range of whole pages, use
 * the fast Linux page allocator instead, directly.
 */
extern struct simp * simp_create(char * name, long size,
				 structor first_ctor, 
				 structor again_ctor, 
				 structor dtor);

/* alloc / dealloc routines */
extern void * simp_alloc(struct simp * simp);
extern void simp_free(void * objp);

/* garbage collection */
extern long simp_garbage(void);

#endif