From 5730d6c04258e192195bfbbbed76d68fd78ed458 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Wed, 12 Jan 2022 20:26:08 +0800 Subject: Implement a simple hash table. It is a very basic and simple hash table. It is so simple that I hesitate to call it a hash table. Anyways, I think it suffices for my purposes here. * Makefile.am: Add necessary files. * grammar.c (new_tnt_string): Formatting. * ht.c (new_ht): Constructor (destroy_ht): Destructor (ht_expand): Rehash (ht_insert, ht_delete, ht_find): Main functions. * list.c (add_to_list, list_assure_size): Modify the use of realloc. * test/check_ht.c: Ensure this is working correctly. * util.c (read_entire_file): Modify the use of realloc. --- src/Makefile.am | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/Makefile.am') diff --git a/src/Makefile.am b/src/Makefile.am index f43fbee..a708ba4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,9 +2,9 @@ AM_CFLAGS = -Wall -Wextra noinst_LIBRARIES = libeps.a libeps_a_SOURCES = grammar.c list.c util.c reader.c \ -str.c utf8.c dfa.c \ +str.c utf8.c dfa.c ht.c \ grammar.h list.h util.h reader.h \ -str_partial.h str.h utf8.h dfa.h +str_partial.h str.h utf8.h dfa.h ht.h libeps_a_CFLAGS = $(AM_CFLAGS) --pedantic @@ -21,7 +21,8 @@ CLEANFILES = TAGS # tests -check_PROGRAMS = check_list check_grammar check_reader check_dfa +check_PROGRAMS = check_list check_grammar check_reader check_dfa \ +check_ht check_list_SOURCES = test/check_list.c list.c @@ -33,6 +34,8 @@ str.c utf8.c util.c check_dfa_SOURCES = test/check_dfa.c dfa.c list.c str.c utf8.c +check_ht_SOURCES = test/check_ht.c ht.c + TESTS = $(check_PROGRAMS) AM_COLOR_TESTS = always -- cgit v1.2.3-18-g5258