aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@home.transmeta.com>2003-06-24 12:45:48 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:00:54 -0700
commit1bcc92138dcdf718dc3e0c694565f56e669d6ee3 (patch)
tree3af10b7ff76cdcadb801c3ea2b4e09bfeeae0c7a
parentf40c00a25222b3716f70be9865475ddca4ffb61f (diff)
downloadsparse-1bcc92138dcdf718dc3e0c694565f56e669d6ee3.tar.gz
sparse-1bcc92138dcdf718dc3e0c694565f56e669d6ee3.tar.xz
sparse-1bcc92138dcdf718dc3e0c694565f56e669d6ee3.zip
Do a proper scope allocator, don't use the "bytes" allocator that doesn't
have any alignment guarantees.
-rw-r--r--lib.c4
-rw-r--r--lib.h1
-rw-r--r--scope.c2
3 files changed, 5 insertions, 2 deletions
diff --git a/lib.c b/lib.c
index d6751a9..e89bc9b 100644
--- a/lib.c
+++ b/lib.c
@@ -17,6 +17,7 @@
#include "parse.h"
#include "symbol.h"
#include "expression.h"
+#include "scope.h"
struct token *skip_to(struct token *token, int op)
{
@@ -146,6 +147,7 @@ struct allocator_struct symbol_allocator = { "symbols", NULL, __alignof__(struct
struct allocator_struct expression_allocator = { "expressions", NULL, __alignof__(struct expression), CHUNK };
struct allocator_struct statement_allocator = { "statements", NULL, __alignof__(struct statement), CHUNK };
struct allocator_struct string_allocator = { "strings", NULL, __alignof__(struct statement), CHUNK };
+struct allocator_struct scope_allocator = { "scopes", NULL, __alignof__(struct scope), CHUNK };
struct allocator_struct bytes_allocator = { "bytes", NULL, 1, CHUNK };
#define __ALLOCATOR(type, size, x) \
@@ -165,7 +167,7 @@ struct allocator_struct bytes_allocator = { "bytes", NULL, 1, CHUNK };
ALLOCATOR(ident); ALLOCATOR(token); ALLOCATOR(symbol);
ALLOCATOR(expression); ALLOCATOR(statement); ALLOCATOR(string);
-__ALLOCATOR(void, 0, bytes);
+ALLOCATOR(scope); __ALLOCATOR(void, 0, bytes);
int ptr_list_size(struct ptr_list *head)
{
diff --git a/lib.h b/lib.h
index 4239e0a..4719c90 100644
--- a/lib.h
+++ b/lib.h
@@ -45,6 +45,7 @@ DECLARE_ALLOCATOR(symbol);
DECLARE_ALLOCATOR(expression);
DECLARE_ALLOCATOR(statement);
DECLARE_ALLOCATOR(string);
+DECLARE_ALLOCATOR(scope);
__DECLARE_ALLOCATOR(void, bytes);
#define LIST_NODE_NR (29)
diff --git a/scope.c b/scope.c
index 4938e9d..98c74be 100644
--- a/scope.c
+++ b/scope.c
@@ -28,7 +28,7 @@ void bind_scope(struct symbol *sym, struct scope *scope)
static void start_scope(struct scope **s)
{
- struct scope *scope = __alloc_bytes(sizeof(*scope));
+ struct scope *scope = __alloc_scope(0);
memset(scope, 0, sizeof(*scope));
scope->next = *s;
*s = scope;