sound: snd_ctl_remove_user_ctl: prevent removal of kernel controls
[linux-2.6/cjktty.git] / include / linux / flex_array.h
blob23c1ec79a31b224470cc0d8e235ebc0a661baa17
1 #ifndef _FLEX_ARRAY_H
2 #define _FLEX_ARRAY_H
4 #include <linux/types.h>
5 #include <asm/page.h>
7 #define FLEX_ARRAY_PART_SIZE PAGE_SIZE
8 #define FLEX_ARRAY_BASE_SIZE PAGE_SIZE
10 struct flex_array_part;
13 * This is meant to replace cases where an array-like
14 * structure has gotten too big to fit into kmalloc()
15 * and the developer is getting tempted to use
16 * vmalloc().
19 struct flex_array {
20 union {
21 struct {
22 int element_size;
23 int total_nr_elements;
24 struct flex_array_part *parts[0];
27 * This little trick makes sure that
28 * sizeof(flex_array) == PAGE_SIZE
30 char padding[FLEX_ARRAY_BASE_SIZE];
34 #define FLEX_ARRAY_INIT(size, total) { { {\
35 .element_size = (size), \
36 .total_nr_elements = (total), \
37 } } }
39 struct flex_array *flex_array_alloc(int element_size, int total, gfp_t flags);
40 int flex_array_prealloc(struct flex_array *fa, int start, int end, gfp_t flags);
41 void flex_array_free(struct flex_array *fa);
42 void flex_array_free_parts(struct flex_array *fa);
43 int flex_array_put(struct flex_array *fa, int element_nr, void *src,
44 gfp_t flags);
45 void *flex_array_get(struct flex_array *fa, int element_nr);
47 #endif /* _FLEX_ARRAY_H */