zif-string

zif-string — Reference counted strings

Synopsis

                    ZifString;
#define             zif_string_get_value                (string)
ZifString *         zif_string_new                      (const gchar *value);
ZifString *         zif_string_new_value                (gchar *value);
ZifString *         zif_string_new_static               (const gchar *value);
ZifString *         zif_string_ref                      (ZifString *string);
ZifString *         zif_string_unref                    (ZifString *string);

Description

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

Details

ZifString

typedef struct {
	gchar		*value;
	/* other stuff */
} ZifString;


zif_string_get_value()

#define zif_string_get_value(string)		(string->value)


zif_string_new ()

ZifString *         zif_string_new                      (const gchar *value);

Creates a new referenced counted string

value :

string to copy

Returns :

New allocated string

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 value as it is now owned by the ZifString.

value :

string to use

Returns :

New allocated string

Since 0.1.0


zif_string_new_static ()

ZifString *         zif_string_new_static               (const gchar *value);

Creates a new referenced counted string, using the static memory. You MUST not free the static string that backs this object. Use this function with care.

value :

string to use

Returns :

New allocated string

Since 0.1.3


zif_string_ref ()

ZifString *         zif_string_ref                      (ZifString *string);

Increases the reference count on the object.

string :

A ZifString

Returns :

A ZifString

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 :

A ZifString

Returns :

A ZifString

Since 0.1.0