lambdamoo/str_intern.h
Roger Crew fdeb879334 normalize .h wrappers
really need to be sure .h files are not getting multiply included
(I had thought this was already best-practice from the K&R days).

new rules for forming the symbol from the filename:
(1)  capitalize each word of the filename,
(2)  final 'H' is capitalized
  ... *unless* the rest of the filename is an initialism (AST, DB)
  which would make the resulting symbol all-caps (AST_H, DB_H)
  which we do not want (since it might collide with something real)
  so use a small 'h' in those cases (AST_h, DB_h)
(3) make sure this preprocessor symbol is used *NOWHERE* else.

    --wrog
2025-09-29 00:44:47 -07:00

25 lines
779 B
C

/* A string intern table.
*
* The intern table holds a list of strings. Given a new string, we
* either str_dup it and add it to the table or return a ref to the
* existing copy of the string from the table if present.
*
* This implementation has one big intern table that's designed to be
* used during db load then freed all at once. It might be
* interesting to intern all strings even during runtime. Somebody
* else can do this.
* */
#ifndef Str_Intern_H
#define Str_Intern_H 1
/* 0 for a default size */
extern void str_intern_open(int table_size);
extern void str_intern_close(void);
/* Make an immutable copy of s. If there's an intern table open,
possibly share storage. */
extern const char *str_intern(const char *s);
#endif /* !Str_Intern_H */