close
Memory Allocation: "g_new()
#define g_new(struct_type, n_structs)
Allocates n_structs elements of type struct_type. The returned pointer is cast to a pointer to the given type. If n_structs is 0 it returns NULL.
Since the returned pointer is already casted to the right type, it is normally unnecessary to cast it explicitly, and doing so might hide memory allocation errors.
struct_type : the type of the elements to allocate
n_structs : the number of elements to allocate
Returns : a pointer to the allocated memory, cast to a pointer to struct_type
g_new0()
#define g_new0(struct_type, n_structs)
Allocates n_structs elements of type struct_type, initialized to 0's. The returned pointer is cast to a pointer to the given type. If n_structs is 0 it returns NULL.
Since the returned pointer is already casted to the right type, it is normally unnecessary to cast it explicitly, and doing so might hide memory allocation errors.
struct_type : the type of the elements to allocate.
n_structs : the number of elements to allocate.
Returns : a pointer to the allocated memory, cast to a pointer to struct_type.
g_renew()
#define g_renew(struct_type, mem, n_structs)
Reallocates the memory pointed to by mem, so that it now has space for n_structs elements of type struct_type. It returns"
#define g_new(struct_type, n_structs)
Allocates n_structs elements of type struct_type. The returned pointer is cast to a pointer to the given type. If n_structs is 0 it returns NULL.
Since the returned pointer is already casted to the right type, it is normally unnecessary to cast it explicitly, and doing so might hide memory allocation errors.
struct_type : the type of the elements to allocate
n_structs : the number of elements to allocate
Returns : a pointer to the allocated memory, cast to a pointer to struct_type
g_new0()
#define g_new0(struct_type, n_structs)
Allocates n_structs elements of type struct_type, initialized to 0's. The returned pointer is cast to a pointer to the given type. If n_structs is 0 it returns NULL.
Since the returned pointer is already casted to the right type, it is normally unnecessary to cast it explicitly, and doing so might hide memory allocation errors.
struct_type : the type of the elements to allocate.
n_structs : the number of elements to allocate.
Returns : a pointer to the allocated memory, cast to a pointer to struct_type.
g_renew()
#define g_renew(struct_type, mem, n_structs)
Reallocates the memory pointed to by mem, so that it now has space for n_structs elements of type struct_type. It returns"
全站熱搜
留言列表