1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-06 09:43:13 +02:00

core: add shared strings to reduce memory usage

Shared strings are stored in a hashtable with pointer for keys (values are not
used).

The key has a reference count + the string.
The initial reference count is set to 1 and is incremented each time the same
string is asked.

When removing a shared string, the reference count is decremented.
If it becomes 0, then the shared string is removed from the hashtable (and then
the string is really destroyed).
This commit is contained in:
Sebastien Helleu
2013-08-10 17:25:14 +02:00
parent 784de68a5f
commit 49aacc853c
3 changed files with 168 additions and 0 deletions
+3
View File
@@ -84,5 +84,8 @@ extern char *string_replace_with_callback (const char *string,
char *(*callback)(void *data, const char *text),
void *callback_data,
int *errors);
extern const char *string_shared_get (const char *string);
extern void string_shared_free (const char *string);
extern void string_end ();
#endif /* __WEECHAT_STRING_H */