implement reference counted strings

- on glib >=2.58, use the implementation provided by glib
- otherwise, a hash table will contain the strings
This commit is contained in:
ailin-nemui 2019-08-13 15:29:55 +02:00
commit ad7ad063ca
6 changed files with 133 additions and 0 deletions

24
src/core/refstrings.h Normal file
View file

@ -0,0 +1,24 @@
#ifndef IRSSI_CORE_REFSTRINGS_H
#define IRSSI_CORE_REFSTRINGS_H
#include <glib.h>
#if GLIB_CHECK_VERSION(2, 58, 0)
#define i_refstr_init() /* nothing */
#define i_refstr_release(str) ((str) == NULL ? NULL : g_ref_string_release(str))
#define i_refstr_intern(str) ((str) == NULL ? NULL : g_ref_string_new_intern(str))
#define i_refstr_deinit() /* nothing */
#define i_refstr_table_size_info() NULL
#else
void i_refstr_init(void);
char *i_refstr_intern(const char *str);
void i_refstr_release(char *str);
void i_refstr_deinit(void);
char *i_refstr_table_size_info(void);
#endif
#endif