639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainen#ifndef STR_TABLE_H
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainen#define STR_TABLE_H
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainen
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainen/* Hash table containing string -> refcount. */
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainen
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainenstruct str_table *str_table_init(void);
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainenvoid str_table_deinit(struct str_table **table);
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainen
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainen/* Returns TRUE if there are no referenced strings in the table. */
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainenbool str_table_is_empty(struct str_table *table);
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainen
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainen/* Return string allocated from the strtable and increase its reference
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainen count. */
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainenconst char *str_table_ref(struct str_table *table, const char *str);
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainen/* Decrease string's reference count, freeing it if it reaches zero.
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainen The str pointer must have been returned by the str_table_ref(). */
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainenvoid str_table_unref(struct str_table *table, const char **str);
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainen
639587335dfe5d66dc7034817b3e685458ecbee1Timo Sirainen#endif