zif-string

zif-string — Create and manage reference counted strings

Synopsis

typedef             ZifString;
ZifString *         zif_string_new                      (const gchar *value);
ZifString *         zif_string_new_value                (gchar *value);
ZifString *         zif_string_ref                      (ZifString *string);
ZifString *         zif_string_unref                    (ZifString *string);
const gchar *       zif_string_get_value                (ZifString *string);

Description

To avoid frequent malloc/free, we use reference counted strings to optimise many of the zif internals.

Details

ZifString

typedef struct ZifString ZifString;


zif_string_new ()

ZifString *         zif_string_new                      (const gchar *value);

Creates a new referenced counted string

value :

string to copy

Returns :

New allocated object

Since 0.1.0


zif_string_new_value ()

ZifString *         zif_string_new_value                (gchar *value);

Creates a new referenced counted string, using the allocated memory. Do not free this string as it is now owned by the ZifString.

value :

string to use

Returns :

New allocated object

Since 0.1.0


zif_string_ref ()

ZifString *         zif_string_ref                      (ZifString *string);

Increases the reference count on the object.

string :

the ZifString object

Returns :

the ZifString object

Since 0.1.0


zif_string_unref ()

ZifString *         zif_string_unref                    (ZifString *string);

Decreses the reference count on the object, and frees the value if it calls to zero.

string :

the ZifString object

Returns :

the ZifString object

Since 0.1.0


zif_string_get_value ()

const gchar *       zif_string_get_value                (ZifString *string);

Returns the string stored in the ZifString. This value is only valid while the ZifString's reference count > 1.

string :

the ZifString object

Returns :

string value

Since 0.1.0