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:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user