If we call compilerkit_symbol_new('a') twice, it allocates two objects, which wastes space. The second time compilerkit_symbol_new('a') returns, it should return the instance of symbol a allocated previously.
Modify compilerkit_symbol_new to use a statically allocated hash table to track symbol instances, keyed by the character. Also, write a test case in tests/symbol-test.c that compares the pointers returned by compilerkit_symbol_new to ensure it's doing the job correctly.
If we call
compilerkit_symbol_new('a')
twice, it allocates two objects, which wastes space. The second timecompilerkit_symbol_new('a')
returns, it should return the instance of symbola
allocated previously.Modify
compilerkit_symbol_new
to use a statically allocated hash table to track symbol instances, keyed by the character. Also, write a test case intests/symbol-test.c
that compares the pointers returned bycompilerkit_symbol_new
to ensure it's doing the job correctly.