macros

macros —

Synopsis




#define     CAPTIVE_FAKEUSE
#define     captive_newn                    (objp,n)
#define     captive_new0n                   (objp,n)
#define     captive_renewn                  (objp,n)
#define     captive_new                     (objp)
#define     captive_new0                    (objp)
#define     captive_newn_alloca             (objp,n)
#define     captive_new0n_alloca            (objp,n)
#define     captive_new_alloca              (objp)
#define     captive_new0_alloca             (objp)
#define     captive_memdup                  (destp,srcp)
#define     captive_va_arg                  (objp,ap)
#define     CAPTIVE_MEMZERO                 (objp)
#define     captive_printf_alloca           (format,args...)
#define     captive_strdup_alloca           (string)
#define     CAPTIVE_ROUND_DOWN              (pointer,fragment)
#define     CAPTIVE_ROUND_DOWN64            (pointer,fragment)
#define     CAPTIVE_ROUND_DOWN_EXCEEDING    (pointer,fragment)
#define     CAPTIVE_ROUND_DOWN_EXCEEDING64  (pointer,fragment)
#define     CAPTIVE_ROUND_UP                (pointer,fragment)
#define     CAPTIVE_ROUND_UP64              (pointer,fragment)

Description

Details

CAPTIVE_FAKEUSE

#define CAPTIVE_FAKEUSE =0

Prevent 'might be used uninitialized' warning. Macro will fakes the use of the variable as sometimes GCC can't code flow analyse C correctly.

g_some_type some_variable CAPTIVE_FAKEUSE;


captive_newn()

#define captive_newn(objp,n) ((objp)=g_new(typeof(*(objp)),(n)))

Macro to allocate n objects of type *objp and to assign the resulting pointer to objp. Allocated memory may contain garbage.

Returns: Initialized objp value as the memory of size sizeof(typeof(*objp))*n. Value NULL is returned iff n==0;

objp : Variable with the pointer to the objects wished to be allocated. Original value is discarded.
n : Numbers of objects to be allocated. Value 0 is permitted (NULL assignment effect).

captive_new0n()

#define captive_new0n(objp,n) ((objp)=g_new0(typeof(*(objp)),(n)))

Macro to allocate n objects of type *objp and to assign the resulting pointer to objp. Allocated memory is precleared.

Returns: Initialized objp value as the cleared memory of size sizeof(typeof(*objp))*n. Value NULL is returned iff n==0;

objp : Variable with the pointer to the objects wished to be allocated and precleared. Original value is discarded.
n : Numbers of objects to be allocated. Value 0 is permitted (NULL assignment effect).

captive_renewn()

#define     captive_renewn(objp,n)

Macro to reallocate the original memory stored in objp to the size n objects of type *objp and to assign the resulting pointer to objp. New allocated space may contain garbage. Both objp and n can be nonexclusively passed as zero.

Returns: Initialized objp value as the memory of size sizeof(typeof(*objp))*n. Value NULL is returned iff n==0;

objp : Variable with the pointer to the objects wished to be reallocated. Value NULL is permitted (g_malloc() effect).
n : Numbers of objects to be allocated. Value 0 is permitted (g_free() effect).

captive_new()

#define captive_new(objp) (captive_newn((objp),1))

Macro to allocate one object of type *objp and to assign the resulting pointer to objp. Allocated memory may contain garbage. Equivalent to captive_newn(objp,1) call.

Returns: Initialized objp value as the memory of size sizeof(typeof(*objp)). Value NULL is never returned.

objp : Variable with the pointer to the object wished to be allocated. Original value is discarded.

captive_new0()

#define captive_new0(objp) (captive_new0n((objp),1))

Macro to allocate one object of type *objp and to assign the resulting pointer to objp. Allocated memory is precleared. Equivalent to captive_new0n(objp,1) call.

Returns: Initialized objp value as the cleared memory of size sizeof(typeof(*objp)). Value NULL is never returned.

objp : Variable with the pointer to the object wished to be allocated and precleared. Original value is discarded.

captive_newn_alloca()

#define     captive_newn_alloca(objp,n)

Macro to allocate n objects of type *objp and to assign the resulting pointer to objp. Allocated memory may contain garbage.

Memory is allocated on the stack frame by g_alloca() and it will be automatically deallocated during exit of current function (or current block if variable sized variables present there). You cannot deallocate or reallocate such memory in any other way.

Returns: Initialized objp value as the memory of size sizeof(typeof(*objp))*n. Value NULL is returned iff n==0;

objp : Variable with the pointer to the objects wished to be allocated. Original value is discarded.
n : Numbers of objects to be allocated. Value 0 is permitted (NULL assignment effect).

captive_new0n_alloca()

#define     captive_new0n_alloca(objp,n)

Macro to allocate n objects of type *objp and to assign the resulting pointer to objp. Allocated memory is precleared.

Memory is allocated on the stack frame by g_alloca() and it will be automatically deallocated during exit of current function (or current block if variable sized variables present there). You cannot deallocate or reallocate such memory in any other way.

Returns: Initialized objp value as the cleared memory of size sizeof(typeof(*objp))*n. Value NULL is returned iff n==0;

objp : Variable with the pointer to the objects wished to be allocated and precleared. Original value is discarded.
n : Numbers of objects to be allocated. Value 0 is permitted (NULL assignment effect).

captive_new_alloca()

#define captive_new_alloca(objp) (captive_newn_alloca((objp),1))

Macro to allocate one object of type *objp and to assign the resulting pointer to objp. Allocated memory may contain garbage. Equivalent to captive_newn_alloca(objp,1) call.

Memory is allocated on the stack frame by g_alloca() and it will be automatically deallocated during exit of current function (or current block if variable sized variables present there). You cannot deallocate or reallocate such memory in any other way.

Returns: Initialized objp value as the memory of size sizeof(typeof(*objp)). Value NULL is never returned.

objp : Variable with the pointer to the object wished to be allocated. Original value is discarded.

captive_new0_alloca()

#define captive_new0_alloca(objp) (captive_new0n_alloca((objp),1))

Macro to allocate one object of type *objp and to assign the resulting pointer to objp. Allocated memory is precleared. Equivalent to captive_new0n_alloca(objp,1) call.

Returns: Initialized objp value as the cleared memory of size sizeof(typeof(*objp)).

objp : Variable with the pointer to the object wished to be allocated and precleared. Original value is discarded.

captive_memdup()

#define     captive_memdup(destp,srcp)

Macro to similiar to g_memdup() but the object size is detected automatically. Size of destp object and srcp object must be the same.

You must free the allocated memory of destp by g_free().

Returns: Initialized destp value as the copied memory of size sizeof(typeof(*srcp)).

destp : Variable with the pointer to the target object wished to be allocated. Original value is discarded.
srcp : Pointer to the source object to be copied to destp.

captive_va_arg()

#define captive_va_arg(objp,ap) ((objp)=va_arg((ap),typeof(objp)))

Automatically determines the size of objp. Equivalent to objp=va_arg(ap,typeof(objp)) call.

Returns: Initialized objp value.

objp : Variable to be filled from the next argument of ap.
ap : Initialized va_list type.

CAPTIVE_MEMZERO()

#define CAPTIVE_MEMZERO(objp) (memset((objp),0,sizeof(*(objp))))

Clears the sizeof(*objp) bytes of the given pointer with memset(). Pass _pointer_ to the object to be cleared.

objp : Pointer to the variable to be cleared.

captive_printf_alloca()

#define     captive_printf_alloca(format,args...)

Format the given format string format as in sprintf(). Output buffer is allocated automatically and it does not need to be deallocated manually as it is managed by g_alloca().

Returns: Formatted output string located in g_alloca() memory.

format : Format string. See the sprintf() documentation.
args... : Arguments for format. See the sprintf() documentation.

captive_strdup_alloca()

#define     captive_strdup_alloca(string)

Macro to do g_strdup() equivalent in g_alloca() style.

Memory is allocated on the stack frame by g_alloca() and it will be automatically deallocated during exit of current function (or current block if variable sized variables present there). You cannot deallocate or reallocate such memory in any other way.

Returns: Duplicated string. You may modify its items if the length is not changed.

string : const gchar * string to duplicate.

CAPTIVE_ROUND_DOWN()

#define     CAPTIVE_ROUND_DOWN(pointer,fragment)

General pointer down-rounding macro. Already aligned pointer is left as is.

glib NOTE: YOU MAY NOT STORE POINTERS IN INTEGERS.

Returns: Down-rounded pointer to the integer multiple of fragment. Resulting pointer has the same type as pointer.

pointer : Arbitrary pointer type.
fragment : Amount of 'sizeof(char)' to align pointer down to. This size will be typically a power of 2. Value less or equal to 0 is forbidden.

CAPTIVE_ROUND_DOWN64()

#define     CAPTIVE_ROUND_DOWN64(pointer,fragment)

pointer :
fragment :

CAPTIVE_ROUND_DOWN_EXCEEDING()

#define     CAPTIVE_ROUND_DOWN_EXCEEDING(pointer,fragment)

Detects current non-aligned amount of data exceeding over integer multiple of fragment. It will return value 0 for an aligned pointer.

glib NOTE: YOU MAY NOT STORE POINTERS IN INTEGERS.

Returns: gsize typed number of bytes exceeding over integer multiple of fragment.

pointer : Arbitrary pointer type.
fragment : Amount of 'sizeof(char)' to detect down-alignment amount of pointer for. This size will be typically a power of 2. Value less or equal to 0 is forbidden.

CAPTIVE_ROUND_DOWN_EXCEEDING64()

#define     CAPTIVE_ROUND_DOWN_EXCEEDING64(pointer,fragment)

pointer :
fragment :

CAPTIVE_ROUND_UP()

#define     CAPTIVE_ROUND_UP(pointer,fragment)

General pointer up-rounding macro. Already aligned pointer is left as is.

glib NOTE: YOU MAY NOT STORE POINTERS IN INTEGERS.

Returns: Up-rounded pointer to the integer multiple of fragment. Resulting pointer has the same type as pointer.

pointer : Arbitrary pointer type.
fragment : Amount of 'sizeof(char)' to align pointer up to. This size will be typically a power of 2. Value less or equal to 0 is forbidden.

CAPTIVE_ROUND_UP64()

#define     CAPTIVE_ROUND_UP64(pointer,fragment)

pointer :
fragment :