X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=walk_statements.c;h=8a4cbc166f600d5730d9c194cb89d55a250201c1;hb=7923d6be3b8493730fe233ab3c4c390099534cbe;hp=9e0c49120a3bbe8e7e02317e6427be8bdc47b1b4;hpb=a25daef22bc375bea28f7c8965c69edec5679e84;p=cparser diff --git a/walk_statements.c b/walk_statements.c index 9e0c491..8a4cbc1 100644 --- a/walk_statements.c +++ b/walk_statements.c @@ -116,11 +116,11 @@ static void walk_initializer(const initializer_t *initializer, } static void walk_declarations(const entity_t* entity, - const entity_t* const end, + const entity_t* const last, statement_callback const callback, void *const env) { - for (; entity != end; entity = entity->base.next) { + for (; entity != NULL; entity = entity->base.next) { /* we only look at variables */ if (entity->kind != ENTITY_VARIABLE) continue; @@ -130,6 +130,9 @@ static void walk_declarations(const entity_t* entity, if (initializer != NULL) { walk_initializer(initializer, callback, env); } + + if (entity == last) + break; } } @@ -197,8 +200,7 @@ void walk_statements(statement_t *const stmt, statement_callback const callback, case STATEMENT_DECLARATION: walk_declarations(stmt->declaration.declarations_begin, - stmt->declaration.declarations_end->base.next, - callback, env); + stmt->declaration.declarations_end, callback, env); return; case STATEMENT_MS_TRY: