Memory Allocation

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"

留言

Google

本月熱門文章

香港朋友,真的對唔住,台灣出了這種中共的幫兇!

堅持5個月!反送中示威者六大特色 6 features of Hong Kong Anti-ELAB Protesters│老外看香港│郝毅博 Ben Hedges│新唐人電視台

[黑金] 台南88槍擊案主犯國民黨學甲區黨部主委王文宗 也擔任統促黨幹部

熱門文章

企鵝妹/柳允進 史上最暈的TT三分鐘完整版一次看個夠

陳昇 Bobby Chen【把悲傷留給自己 I left sadness to myself】Official Music Video

裝潢師傅貼圖來了唷

香港朋友,真的對唔住,台灣出了這種中共的幫兇!

新手自建監控雲最快的方式:推薦QNAP NAS 搭配QVR Pro

2020 中華民國 台灣 失業補助申請方式 失業給付申請

香港朋友看服貿 - 嗨,我是香港人,一個CEPA的受害者。

堅持5個月!反送中示威者六大特色 6 features of Hong Kong Anti-ELAB Protesters│老外看香港│郝毅博 Ben Hedges│新唐人電視台