diff options
author | Max Kellermann <max@duempel.org> | 2008-10-31 09:17:52 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-31 09:17:52 +0100 |
commit | e5ef2d8a375865c8b5058c1107d2b32ce89b7c9d (patch) | |
tree | fcb9465ec293d3d78021f74a4ff7fce8da9715e0 /src | |
parent | 8f37f7c8386d2267b7f56f883e34e4997a955abd (diff) | |
download | mpd-e5ef2d8a375865c8b5058c1107d2b32ce89b7c9d.tar.gz mpd-e5ef2d8a375865c8b5058c1107d2b32ce89b7c9d.tar.xz mpd-e5ef2d8a375865c8b5058c1107d2b32ce89b7c9d.zip |
client: removed list_cache
The list cache aims to save memory allocations, and complicates the
code a bit. We should rather use GLib slices later, which are easy to
use.
Diffstat (limited to 'src')
-rw-r--r-- | src/client.c | 35 |
1 files changed, 1 insertions, 34 deletions
diff --git a/src/client.c b/src/client.c index 4f6aaf876..c9123d986 100644 --- a/src/client.c +++ b/src/client.c @@ -56,14 +56,6 @@ static size_t client_max_command_list_size = static size_t client_max_output_buffer_size = CLIENT_MAX_OUTPUT_BUFFER_SIZE_DEFAULT; -/* maybe make conf option for this, or... 32 might be good enough */ -static long int client_list_cache_size = 32; - -/* shared globally between all clients: */ -static struct strnode *list_cache; -static struct strnode *list_cache_head; -static struct strnode *list_cache_tail; - struct client { struct list_head siblings; @@ -165,12 +157,7 @@ static void free_cmd_list(struct strnode *list) while (tmp) { struct strnode *next = tmp->next; - if (tmp >= list_cache_head && tmp <= list_cache_tail) { - /* inside list_cache[] array */ - tmp->data = NULL; - tmp->next = NULL; - } else - free(tmp); + free(tmp); tmp = next; } } @@ -190,25 +177,11 @@ static void cmd_list_clone(struct client *client) static void new_cmd_list_ptr(struct client *client, char *s, const int size) { - int i; struct strnode *new; - if (!client->cmd_list_dup) { - for (i = client_list_cache_size - 1; i >= 0; --i) { - if (list_cache[i].data) - continue; - new = &(list_cache[i]); - new->data = s; - /* implied in free_cmd_list() and init: */ - /* last->next->next = NULL; */ - goto out; - } - } - /* allocate from the heap */ new = client->cmd_list_dup ? new_strnode_dup(s, size) : new_strnode(s); -out: if (client->cmd_list) { client->cmd_list_tail->next = new; client->cmd_list_tail = new; @@ -609,10 +582,6 @@ void client_manager_init(void) } client_max_output_buffer_size = tmp * 1024; } - - list_cache = xcalloc(client_list_cache_size, sizeof(struct strnode)); - list_cache_head = &(list_cache[0]); - list_cache_tail = &(list_cache[client_list_cache_size - 1]); } static void client_close_all(void) @@ -622,8 +591,6 @@ static void client_close_all(void) list_for_each_entry_safe(client, n, &clients, siblings) client_close(client); num_clients = 0; - - free(list_cache); } void client_manager_deinit(void) |