From 36cac270be19b769530a7b68ca6d4e3b79452e41 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Thu, 26 Apr 2001 01:07:44 +0000 Subject: Modified to match e_strv_get behaviour. Assert on bad cases, and return "" 2001-04-26 Not Zed * e-memory.c (e_poolv_get): Modified to match e_strv_get behaviour. Assert on bad cases, and return "" rather than NULL for empty/unset strings. (e_poolv_new): Simplify the mutex cases, only have a single mutex for mempool and hashtable references. (e_poolv_set): Simplify mutex code. Fixed a #ifdef orde prob in profile stuff. Always copy string to our own memory when we add it to the hash, even if we free it; I think this would have led to dangling references otherwise. (e_poolv_destroy): Renamed from poolv_free, for consistency with the rest of the allocators here. (e_poolv_set): Add optional refcounting code here, not currently enabled/used, but should make proper string collection work easily. (e_poolv_destroy): Unrefcount the strings here. (e_poolv_cpy): Add refcounting code here. * e-memory.[ch]: Applied Jacob's patches for 'e-poolv' type, added his name to the authors list. svn path=/trunk/; revision=9570 --- e-util/e-memory.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'e-util/e-memory.h') diff --git a/e-util/e-memory.h b/e-util/e-memory.h index 911bb36b7a..c271914d5f 100644 --- a/e-util/e-memory.h +++ b/e-util/e-memory.h @@ -1,7 +1,8 @@ /* - * Copyright (C) 2000, Helix Code Inc. + * Copyright (C) 2001, Helix Code Inc. * - * Author: Michael Zucchi + * Authors: Michael Zucchi + * Jacob Berkman * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -62,4 +63,13 @@ EStrv *e_strv_pack(EStrv *strv); char *e_strv_get(EStrv *strv, int index); void e_strv_destroy(EStrv *strv); +/* poolv's are similar to strv's, but they store common strings */ +typedef struct _EPoolv EPoolv; + +EPoolv *e_poolv_new(unsigned int size); +EPoolv *e_poolv_cpy(EPoolv *dest, const EPoolv *src); +EPoolv *e_poolv_set(EPoolv *poolv, int index, char *str, int freeit); +const char *e_poolv_get(EPoolv *poolv, int index); +void e_poolv_destroy(EPoolv *poolv); + #endif /* ! _E_MEMORY_H */ -- cgit v1.2.3