token: Rename token_destroy() to token_uninit().
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 9 May 2021 22:01:34 +0000 (15:01 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 9 May 2021 22:01:34 +0000 (15:01 -0700)
This better fits the convention that "destroy" functions free the argument,
whereas "uninit" frees only the members of the argument structure.

src/language/lexer/lexer.c
src/language/lexer/token.c
src/language/lexer/token.h
tests/language/lexer/scan-test.c

index c322dec54fec94f38939e00fc65d2a105664bd00..7f2d0290a64e0c4f9e1d34ad249491ec35e9a967 100644 (file)
@@ -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;
       }
index 98fb72f14e84633f480f87b761913f73d3d7d876..718f3d07f3d480a1580d59714ee8348e63a38e5e 100644 (file)
@@ -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);
index 8feaf8147298d813ac748c0c9e8134449f91ea09..cab1a8cf9c63d011b3788e8a0123ba7acf19dd34 100644 (file)
@@ -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 *);
 
index 6f76d44f516c4caaadec9ef77b362e6ca8f5c4d3..1eb04338e3b39b183b3c957c68288839ce68d4ab 100644 (file)
@@ -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);