util

util — Utility functions

Stability Level

Stable, unless otherwise indicated

Functions

Types and Values

Description

Functions

IPATCH_UTIL_VALUE_BOOL()

#define             IPATCH_UTIL_VALUE_BOOL(b)

ipatch_util_value_hash ()

guint
ipatch_util_value_hash (GValue *val);

Hash a GValue. The hash value can then be used in a GHashTable for example.

Parameters

val

GValue to hash

 

Returns

Hash value corresponding to the val key.


ipatch_util_garray_value_hash ()

guint
ipatch_util_garray_value_hash (GArray *valarray);

Hash a GArray of GValue elements (as returned by ipatch_item_get_unique_props_array()). The hash value can then be used in a GHashTable for example.

Parameters

valarray

GArray of GValue to hash.

[element-type GValue]

Returns

Hash value corresponding to the sum of all values returned by ipatch_util_value_hash() for each GValue in the array.

Since: 1.1.1


ipatch_util_value_array_hash ()

guint
ipatch_util_value_array_hash (GValueArray *valarray);

ipatch_util_value_array_hash has been deprecated since version 1.1.1 and should not be used in newly-written code.

Use ipatch_util_garray_value_hash() instead, since GValueArray is deprecated in GLib.

Hash a GValueArray. The hash value can then be used in a GHashTable for example.

Parameters

valarray

GValueArray to hash

 

Returns

Hash value corresponding to the sum of all values returned by ipatch_util_value_hash() for each GValue in the array.


ipatch_util_file_size ()

guint64
ipatch_util_file_size (const char *fname,
                       GError **err);

Get the size of a file (tired of using stat every time?).

[skip]

Parameters

fname

Path of file to get size of.

 

err

Location to store error or NULL

 

Returns

File size. Will return 0 on error, but err must be checked if it is set to determine if an error really occurred.


ipatch_util_abs_filename ()

char *
ipatch_util_abs_filename (const char *filename);

Make a file name absolute, if it isn't already.

[skip]

Parameters

filename

File name to make absolute

 

Returns

Newly allocated filename, converted to an absolute filename (if necessary) or NULL if filename was NULL

Since: 1.1.0


ipatch_util_weakref_destroy ()

void
ipatch_util_weakref_destroy (gpointer value);

A GDestroyNotify function for freeing a slice allocated GWeakRef.

[skip]

Parameters

value

Slice allocated GWeakRef to destroy

 

Since: 1.1.0


ipatch_util_strncpy_pad ()

void
ipatch_util_strncpy_pad (char *dest,
                         const char *src,
                         gsize n);

Copy up to n bytes of src into dest : like strncpy(dest, src, n), truncating without a trailing NUL if src is n bytes or longer, and zero-padding the remainder of dest if src is shorter than n bytes. Used when writing fixed-width name fields into binary file formats (SoundFont, DLS, GigaSampler, Spectralis) where truncation without a trailing NUL is valid/expected once the field is exactly full.

Implemented without calling strncpy() directly so this deliberate truncate-and-pad usage doesn't trip GCC's -Wstringop-truncation, which otherwise (correctly, in general, but not for this specific idiom) flags any strncpy() call where the bound equals the destination size.

Parameters

dest

Destination buffer of exactly n bytes

 

src

Source string to copy (may be NULL, treated as empty)

 

n

Size of dest in bytes

 

Since: 1.1.1

Types and Values

ipatch_util_value_bool_true

extern GValue *ipatch_util_value_bool_true;

ipatch_util_value_bool_false

extern GValue *ipatch_util_value_bool_false;