aboutsummaryrefslogtreecommitdiffstats
path: root/allocate.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-08-03 15:17:19 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2005-08-03 15:17:19 -0700
commitc1d5f8c18c3ee5f7132357ed0ce8fe79884135f9 (patch)
treeb94ff9de443069911d45fb2e178b9ecda43ae69d /allocate.h
parent8cea1f0d96b63965ebf7fa9bf73f30237605c0e2 (diff)
downloadsparse-c1d5f8c18c3ee5f7132357ed0ce8fe79884135f9.tar.gz
sparse-c1d5f8c18c3ee5f7132357ed0ce8fe79884135f9.tar.xz
sparse-c1d5f8c18c3ee5f7132357ed0ce8fe79884135f9.zip
Add function to "protect" allocations from being dropped later
Useful for the initial (shared) token allocations: we do want to drop the per-file tokens once they aren't needed any more, but we don't want to protect the shared global token allocations.
Diffstat (limited to 'allocate.h')
-rw-r--r--allocate.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/allocate.h b/allocate.h
index e75323c..ab6bd0a 100644
--- a/allocate.h
+++ b/allocate.h
@@ -17,6 +17,7 @@ struct allocator_struct {
unsigned int allocations, total_bytes, useful_bytes;
};
+extern void protect_allocations(struct allocator_struct *desc);
extern void drop_all_allocations(struct allocator_struct *desc);
extern void *allocate(struct allocator_struct *desc, unsigned int size);
extern void free_one_entry(struct allocator_struct *desc, void *entry);
@@ -26,11 +27,12 @@ extern void show_allocations(struct allocator_struct *);
extern type *__alloc_##x(int); \
extern void __free_##x(type *); \
extern void show_##x##_alloc(void); \
- extern void clear_##x##_alloc(void);
+ extern void clear_##x##_alloc(void); \
+ extern void protect_##x##_alloc(void);
#define DECLARE_ALLOCATOR(x) __DECLARE_ALLOCATOR(struct x, x)
#define __ALLOCATOR(type, objsize, objalign, objname, x) \
- struct allocator_struct x##_allocator = { \
+ static struct allocator_struct x##_allocator = { \
.name = objname, \
.alignment = objalign, \
.chunking = CHUNK }; \
@@ -49,6 +51,10 @@ extern void show_allocations(struct allocator_struct *);
void clear_##x##_alloc(void) \
{ \
drop_all_allocations(&x##_allocator); \
+ } \
+ void protect_##x##_alloc(void) \
+ { \
+ protect_allocations(&x##_allocator); \
}
#define ALLOCATOR(x, n) __ALLOCATOR(struct x, sizeof(struct x), __alignof__(struct x), n, x)