From: Ben Pfaff Date: Sun, 9 May 2021 22:01:34 +0000 (-0700) Subject: token: Rename token_destroy() to token_uninit(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;ds=sidebyside;h=1d424c5e30a08aa1047c47a2f8a2fe1e02d02a3e;p=pspp token: Rename token_destroy() to token_uninit(). This better fits the convention that "destroy" functions free the argument, whereas "uninit" frees only the members of the argument structure. --- diff --git a/src/language/lexer/lexer.c b/src/language/lexer/lexer.c index c322dec54f..7f2d0290a6 100644 --- a/src/language/lexer/lexer.c +++ b/src/language/lexer/lexer.c @@ -203,13 +203,13 @@ lex_push_token__ (struct lex_source *src) static void lex_source_pop__ (struct lex_source *src) { - token_destroy (&src->tokens[deque_pop_back (&src->deque)].token); + token_uninit (&src->tokens[deque_pop_back (&src->deque)].token); } static void lex_source_pop_front (struct lex_source *src) { - token_destroy (&src->tokens[deque_pop_front (&src->deque)].token); + token_uninit (&src->tokens[deque_pop_front (&src->deque)].token); } /* Advances LEXER to the next token, consuming the current token. */ @@ -989,7 +989,7 @@ lex_match_phrase (struct lexer *lexer, const char *s) if (token.type != SCAN_SKIP) { bool match = lex_tokens_match (lex_next (lexer, i++), &token); - token_destroy (&token); + token_uninit (&token); if (!match) return false; } diff --git a/src/language/lexer/token.c b/src/language/lexer/token.c index 98fb72f14e..718f3d07f3 100644 --- a/src/language/lexer/token.c +++ b/src/language/lexer/token.c @@ -42,7 +42,7 @@ token_init (struct token *token) /* Frees the string that TOKEN contains. */ void -token_destroy (struct token *token) +token_uninit (struct token *token) { if (token != NULL) ss_dealloc (&token->string); diff --git a/src/language/lexer/token.h b/src/language/lexer/token.h index 8feaf81472..cab1a8cf9c 100644 --- a/src/language/lexer/token.h +++ b/src/language/lexer/token.h @@ -36,7 +36,7 @@ struct token { TYPE, NUMBER, SS_LITERAL_INITIALIZER (STRING) } void token_init (struct token *); -void token_destroy (struct token *); +void token_uninit (struct token *); char *token_to_string (const struct token *); diff --git a/tests/language/lexer/scan-test.c b/tests/language/lexer/scan-test.c index 6f76d44f51..1eb04338e3 100644 --- a/tests/language/lexer/scan-test.c +++ b/tests/language/lexer/scan-test.c @@ -94,7 +94,7 @@ main (int argc, char *argv[]) printf (" \"%.*s\"", (int) token.string.length, token.string.string); printf ("\n"); - token_destroy (&token); + token_uninit (&token); } while (more);