EPoolv

EPoolv

Synopsis

                    EPoolv;
EPoolv *            e_poolv_new                         (guint size);
EPoolv *            e_poolv_set                         (EPoolv *poolv,
                                                         gint index,
                                                         gchar *str,
                                                         gint freeit);
const gchar *       e_poolv_get                         (EPoolv *poolv,
                                                         gint index);
void                e_poolv_destroy                     (EPoolv *poolv);

Description

Details

EPoolv

typedef struct _EPoolv EPoolv;

e_poolv_new ()

EPoolv *            e_poolv_new                         (guint size);

Create a new EPoolv: a string vector which shares a global string pool. An EPoolv can be used to work with arrays of strings which save memory by eliminating duplicated allocations of the same string.

This is useful when you have a log of read-only strings that do not go away and are duplicated a lot, such as email headers.

size :

The number of elements in the poolv, maximum of 254 elements.

Returns :

a new EPoolv

e_poolv_set ()

EPoolv *            e_poolv_set                         (EPoolv *poolv,
                                                         gint index,
                                                         gchar *str,
                                                         gint freeit);

Set a string vector reference. If the caller will no longer be referencing the string, freeit should be TRUE. Otherwise, this will duplicate the string if it is not found in the pool.

poolv :

pooled string vector

index :

index in vector of string

str :

string to set

freeit :

whether the caller is releasing its reference to the string

Returns :

poolv

e_poolv_get ()

const gchar *       e_poolv_get                         (EPoolv *poolv,
                                                         gint index);

Retrieve a string by index. This could possibly just be a macro.

Since the pool is never freed, this string does not need to be duplicated, but should not be modified.

poolv :

pooled string vector

index :

index in vector of string

Returns :

string at that index.

e_poolv_destroy ()

void                e_poolv_destroy                     (EPoolv *poolv);

Free a pooled string vector. This doesn't free the strings from the vector, however.

poolv :

pooled string vector to free