## GLib extras GLib extras |

## Synopsis

    gpointer            (*GOMapFunc)                        (gpointer value);
                        GOMemChunk;
    gboolean            (*GOParseKeyValueFunc)              (const char *name,
                                                             const char *value,
                                                             GError **err,
                                                             gpointer user);
    #define             GO_LIST_APPEND                      (list,
                                                             item)
    #define             GO_LIST_CONCAT                      (list_a,
                                                             list_b)
    #define             GO_LIST_FOREACH                     (list,
                                                             valtype,
                                                             val,
                                                             stmnt)
    #define             GO_LIST_PREPEND                     (list,
                                                             item)
    #define             GO_LIST_REMOVE                      (list,
                                                             item)
    #define             GO_LIST_REVERSE                     (list)
    #define             GO_LIST_SORT                        (list,
                                                             cmp_func)
    #define             GO_SLIST_APPEND                     (list,
                                                             item)
    #define             GO_SLIST_CONCAT                     (list_a,
                                                             list_b)
    #define             GO_SLIST_FOREACH                    (list,
                                                             valtype,
                                                             val,
                                                             stmnt)
    #define             GO_SLIST_PREPEND                    (list,
                                                             item)
    #define             GO_SLIST_REMOVE                     (list,
                                                             item)
    #define             GO_SLIST_REVERSE                    (list)
    #define             GO_SLIST_SORT                       (list,
                                                             cmp_func)
    gint                go_ascii_strcase_equal              (gconstpointer v,
                                                             gconstpointer v2);
    guint               go_ascii_strcase_hash               (gconstpointer v);
    gboolean            go_debug_flag                       (const char *flag);
    void                go_destroy_password                 (char *passwd);
    char const *        go_get_real_name                    (void);
    char const *        go_guess_encoding                   (char const *raw,
                                                             gsize len,
                                                             char const *user_guess,
                                                             GString **utf8_str,
                                                             guint *truncated);
    GSList *            go_hash_keys                        (GHashTable *hash);
    gint                go_list_index_custom                (GList *list,
                                                             gpointer data,
                                                             GCompareFunc cmp_func);
    gpointer            go_mem_chunk_alloc                  (GOMemChunk *chunk);
    gpointer            go_mem_chunk_alloc0                 (GOMemChunk *chunk);
    void                go_mem_chunk_destroy                (GOMemChunk *chunk,
                                                             gboolean expect_leaks);
    void                go_mem_chunk_foreach_leak           (GOMemChunk *chunk,
                                                             GFunc cb,
                                                             gpointer user);
    void                go_mem_chunk_free                   (GOMemChunk *chunk,
                                                             gpointer mem);
    GOMemChunk *        go_mem_chunk_new                    (char const *name,
                                                             gsize user_atom_size,
                                                             gsize chunk_size);
    void                go_object_properties_apply          (GObject *obj,
                                                             GSList *props,
                                                             gboolean changed_only);
    GSList *            go_object_properties_collect        (GObject *obj);
    void                go_object_properties_free           (GSList *props);
    gboolean            go_object_set_property              (GObject *obj,
                                                             const char *property_name,
                                                             const char *user_prop_name,
                                                             const char *value,
                                                             GError **err,
                                                             const char *error_template);
    void                go_object_toggle                    (gpointer object,
                                                             const gchar *property_name);
    gboolean            go_parse_key_value                  (const char *options,
                                                             GError **err,
                                                             GOParseKeyValueFunc handler,
                                                             gpointer user);
    void                go_ptr_array_insert                 (GPtrArray *array,
                                                             gpointer value,
                                                             int index);
    GSList *            go_slist_create                     (gconstpointer item1,
                                                             ...);
    GSList *            go_slist_map                        (GSList const *list,
                                                             GOMapFunc map_func);
    int                 go_str_compare                      (void const *x,
                                                             void const *y);
    void                go_strescape                        (GString *target,
                                                             char const *str);
    void                go_string_append_c_n                (GString *target,
                                                             char c,
                                                             gsize n);
    void                go_string_append_gstring            (GString *target,
                                                             const GString *src);
    void                go_string_replace                   (GString *target,
                                                             gsize pos,
                                                             gssize oldlen,
                                                             const char *txt,
                                                             gssize newlen);
    #define             go_string_slist_copy                (list)
    GSList *            go_strsplit_to_slist                (char const *str,
                                                             gchar delimiter);
    char const *        go_strunescape                      (GString *target,
                                                             char const *str);
    int                 go_unichar_issign                   (gunichar uc);
    gint                go_utf8_collate_casefold            (char const *a,
                                                             char const *b);
    char *              go_utf8_strcapital                  (char const *p,
                                                             gssize len);

## Object Hierarchy

      GBoxed
       +----GOMemChunk

## Description

## Details

### GOMapFunc ()

    gpointer            (*GOMapFunc)                        (gpointer value);

### GOMemChunk

    typedef struct _GOMemChunk GOMemChunk;

### GOParseKeyValueFunc ()

    gboolean            (*GOParseKeyValueFunc)              (const char *name,
                                                             const char *value,
                                                             GError **err,
                                                             gpointer user);

### GO_LIST_APPEND()

    #define             GO_LIST_APPEND(list,item)

### GO_LIST_CONCAT()

    #define             GO_LIST_CONCAT(list_a,list_b)

### GO_LIST_FOREACH()

    #define             GO_LIST_FOREACH(list,valtype,val,stmnt)

### GO_LIST_PREPEND()

    #define             GO_LIST_PREPEND(list,item)

### GO_LIST_REMOVE()

    #define             GO_LIST_REMOVE(list,item)

### GO_LIST_REVERSE()

    #define             GO_LIST_REVERSE(list)

### GO_LIST_SORT()

    #define             GO_LIST_SORT(list,cmp_func)

### GO_SLIST_APPEND()

    #define             GO_SLIST_APPEND(list,item)

### GO_SLIST_CONCAT()

    #define             GO_SLIST_CONCAT(list_a,list_b)

### GO_SLIST_FOREACH()

    #define             GO_SLIST_FOREACH(list,valtype,val,stmnt)

### GO_SLIST_PREPEND()

    #define             GO_SLIST_PREPEND(list,item)

### GO_SLIST_REMOVE()

    #define             GO_SLIST_REMOVE(list,item)

### GO_SLIST_REVERSE()

    #define             GO_SLIST_REVERSE(list)

### GO_SLIST_SORT()

    #define             GO_SLIST_SORT(list,cmp_func)

### go_ascii_strcase_equal ()

    gint                go_ascii_strcase_equal              (gconstpointer v,
                                                             gconstpointer v2);

### go_ascii_strcase_hash ()

    guint               go_ascii_strcase_hash               (gconstpointer v);

### go_debug_flag ()

    gboolean            go_debug_flag                       (const char *flag);

### go_destroy_password ()

    void                go_destroy_password                 (char *passwd);

Overwrite a string holding a password. This is a separate routine to ensure that the compiler does not try to outsmart us.

Note: this does not free the memory.

`passwd` : | The buffer to clear

### go_get_real_name ()

    char const *        go_get_real_name                    (void);

Returns : | a utf8 encoded string with the current user name. Caller should _NOT_ free the result.

### go_guess_encoding ()

    char const *        go_guess_encoding                   (char const *raw,
                                                             gsize len,
                                                             char const *user_guess,
                                                             GString **utf8_str,
                                                             guint *truncated);

### go_hash_keys ()

    GSList *            go_hash_keys                        (GHashTable *hash);

Collects an unordered list of the keys in `hash`.

`hash` : | GHashTable
Returns : | a list which the caller needs to free. The content has not additional references added. [element-type void][transfer container]

### go_list_index_custom ()

    gint                go_list_index_custom                (GList *list,
                                                             gpointer data,
                                                             GCompareFunc cmp_func);

Searched for `data` in `list` and return the corresponding index or -1 if not found.

`list` : | GList. [element-type void]
`data` : | element for which the index is searched for
`cmp_func` : | GCompareFunc. [scope call]
Returns : | the data index in the list.

### go_mem_chunk_alloc ()

    gpointer            go_mem_chunk_alloc                  (GOMemChunk *chunk);

`chunk` : | GOMemChunk
Returns : | an unused memory block. [transfer none]

### go_mem_chunk_alloc0 ()

    gpointer            go_mem_chunk_alloc0                 (GOMemChunk *chunk);

`chunk` : | GOMemChunk
Returns : | an unused memory block filled with 0. [transfer none]

### go_mem_chunk_destroy ()

    void                go_mem_chunk_destroy                (GOMemChunk *chunk,
                                                             gboolean expect_leaks);

### go_mem_chunk_foreach_leak ()

    void                go_mem_chunk_foreach_leak           (GOMemChunk *chunk,
                                                             GFunc cb,
                                                             gpointer user);

Loop over all non-freed memory in the chunk. It's safe to allocate or free from the chunk in the callback.

`chunk` : | GOMemChunk
`cb` : | callback. [scope call]
`user` : | user data for `cb`

### go_mem_chunk_free ()

    void                go_mem_chunk_free                   (GOMemChunk *chunk,
                                                             gpointer mem);

### go_mem_chunk_new ()

    GOMemChunk *        go_mem_chunk_new                    (char const *name,
                                                             gsize user_atom_size,
                                                             gsize chunk_size);

### go_object_properties_apply ()

    void                go_object_properties_apply          (GObject *obj,
                                                             GSList *props,
                                                             gboolean changed_only);

Sets a list of properties for `obj`. The list needs to be a list of alternating GParamSpec and GValue.

`obj` : | GObject
`props` : | the list of properties and their values to apply. [element-type void]
`changed_only` : | whether to restrict calls to `g_object_set_property()` to properties with changed values.

### go_object_properties_collect ()

    GSList *            go_object_properties_collect        (GObject *obj);

Collect all rw properties and their values.

`obj` : | GObject
Returns : | the list of collected properties as GParamSpec and values as GValue. [element-type void][transfer container]

### go_object_properties_free ()

    void                go_object_properties_free           (GSList *props);

Unsezts the values in the list which needs to be a list of alternating GParamSpec and GValue.

`props` : | the list of properties and their values to unset. [element-type void]

### go_object_set_property ()

    gboolean            go_object_set_property              (GObject *obj,
                                                             const char *property_name,
                                                             const char *user_prop_name,
                                                             const char *value,
                                                             GError **err,
                                                             const char *error_template);

### go_object_toggle ()

    void                go_object_toggle                    (gpointer object,
                                                             const gchar *property_name);

Toggle a boolean object property.

`object` : | GObject
`property_name` : | name

### go_parse_key_value ()

    gboolean            go_parse_key_value                  (const char *options,
                                                             GError **err,
                                                             GOParseKeyValueFunc handler,
                                                             gpointer user);

`options` : | Options string.
`err` : | Reference to store GError if parsing fails.
`handler` : | Handler to call for each key-value pair. [scope call]
`user` : | user pointer.

### go_ptr_array_insert ()

    void                go_ptr_array_insert                 (GPtrArray *array,
                                                             gpointer value,
                                                             int index);

Inserts a pointer inside an existing array.

`array` : | a GPtrArray. [element-type void]
`value` : | the pointer to insert
`index` : | where to insert `value`

### go_slist_create ()

    GSList *            go_slist_create                     (gconstpointer item1,
                                                             ...);

Creates a GList from NULL-terminated list of arguments. As the arguments are just copied to the list, the caller owns them.

`item1` : | first item. [allow-none][transfer none]
`...` : | `NULL` terminated list of additional items. [transfer none]
Returns : | created list. [element-type void][transfer container]

### go_slist_map ()

    GSList *            go_slist_map                        (GSList const *list,
                                                             GOMapFunc map_func);

The ownership of the list elements depends on map_func.

`list` : | list of some items. [element-type void]
`map_func` : | mapping function. [scope call]
Returns : | the mapped list. [element-type void][transfer container]

### go_str_compare ()

    int                 go_str_compare                      (void const *x,
                                                             void const *y);

### go_strescape ()

    void                go_strescape                        (GString *target,
                                                             char const *str);

### go_string_append_c_n ()

    void                go_string_append_c_n                (GString *target,
                                                             char c,
                                                             gsize n);

### go_string_append_gstring ()

    void                go_string_append_gstring            (GString *target,
                                                             const GString *src);

### go_string_replace ()

    void                go_string_replace                   (GString *target,
                                                             gsize pos,
                                                             gssize oldlen,
                                                             const char *txt,
                                                             gssize newlen);

### go_string_slist_copy()

    #define	 go_string_slist_copy(list) go_slist_map (list, (GOMapFunc) g_strdup)

### go_strsplit_to_slist ()

    GSList *            go_strsplit_to_slist                (char const *str,
                                                             gchar delimiter);

Splits up string into tokens at delim and returns a string list.

`str` : | String to split
`delimiter` : | Token delimiter
Returns : | string list which you should free after use using function `g_slist_free_full()`, using g_free as second argument. [element-type char][transfer full]

### go_strunescape ()

    char const *        go_strunescape                      (GString *target,
                                                             char const *str);

### go_unichar_issign ()

    int                 go_unichar_issign                   (gunichar uc);

### go_utf8_collate_casefold ()

    gint                go_utf8_collate_casefold            (char const *a,
                                                             char const *b);

### go_utf8_strcapital ()

    char *              go_utf8_strcapital                  (char const *p,
                                                             gssize len);

Similar to g_utf8_strup and g_utf8_strup, except that this function creates a string "Very Much Like: This, One".

`p` : | pointer to UTF-8 string
`len` : | length in bytes, or -1.
Returns : | newly allocated string.