From df8e1592453edd84ec2a6d23c2853710255ee1e4 Mon Sep 17 00:00:00 2001 From: MORIOKA Tomohiko Date: Tue, 16 Apr 2013 17:48:17 +0900 Subject: [PATCH] (cos_string_ent_nil): New variable. (cos_symbol_ent_nil): New variable. (cos_Qnil): New variable. (cos_string_ent_t): New variable. (cos_symbol_ent_t): New variable. (cos_Qt): New variable. (cos_intern): Setup `nil' and `t'. (cos_symbol_table_grow): Release old `table->data'. --- symbol.c | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/symbol.c b/symbol.c index bf544f7..a01b4ce 100644 --- a/symbol.c +++ b/symbol.c @@ -25,6 +25,37 @@ unsigned long cos_hash_c_string_n (const unsigned char *ptr, size_t size); unsigned long cos_symbol_hash_string (COS_String string); +COS_String_ent cos_string_ent_nil = { {COS_OBJECT_PREFIX_OBJECT, + COS_Object_Type_String, + 1}, + 3, "nil"}; + +COS_Symbol_ent cos_symbol_ent_nil = { {COS_OBJECT_PREFIX_OBJECT, + COS_Object_Type_Symbol, + 1}, + &cos_string_ent_nil, + NULL}; + +COS_Symbol cos_Qnil = &cos_symbol_ent_nil; + + +COS_String_ent cos_string_ent_t = { {COS_OBJECT_PREFIX_OBJECT, + COS_Object_Type_String, + 1}, + 1, "t"}; + +COS_Symbol_ent cos_symbol_ent_t = { {COS_OBJECT_PREFIX_OBJECT, + COS_Object_Type_Symbol, + 1}, + &cos_string_ent_t, + NULL}; + +COS_Symbol cos_Qt = &cos_symbol_ent_t; + + +COS_Symbol_Table cos_default_symbol_table = NULL; + + COS_Symbol cos_make_symbol (COS_String string) { @@ -102,8 +133,6 @@ cos_symbol_name (COS_Symbol symbol) } -COS_Symbol_Table cos_default_symbol_table = NULL; - COS_Symbol_Table cos_make_symbol_table_0 (size_t size); void cos_destroy_symbol_table_0 (COS_Symbol_Table hash); @@ -196,8 +225,11 @@ COS_Symbol cos_intern (COS_object name) { if (cos_default_symbol_table == NULL) - cos_default_symbol_table = cos_make_symbol_table(); - + { + cos_default_symbol_table = cos_make_symbol_table(); + cos_symbol_table_set (cos_default_symbol_table, cos_Qnil); + cos_symbol_table_set (cos_default_symbol_table, cos_Qt); + } return cos_symbol_table_intern (cos_default_symbol_table, name); } @@ -257,6 +289,7 @@ cos_symbol_table_grow (COS_Symbol_Table table) } } } + free (table->data); table->size = new_table->size; table->data = new_table->data; free (new_table); -- 1.7.10.4