- 论坛徽章:
- 0
|
原帖由 飞灰橙 于 2008-7-12 02:43 发表 ![]()
不要生气,我帮你找的每一个bug,都是有充分的理由的。
1. g_ptr_array_free, 第二个参数设成TRUE, free的东西不是你想要的。
请翻出g_ptr_array_free 和 g_free 的代码一看便知。
2. ...
- #include <garray.c>
- gpointer*
- g_ptr_array_free (GPtrArray *array,
- gboolean free_segment)
- {
- gpointer* segment;
- g_return_val_if_fail (array, NULL);
- if (free_segment)
- {
- g_free (array->pdata);
- segment = NULL;
- }
- else
- segment = array->pdata;
- G_LOCK (ptr_array_mem_chunk);
- g_mem_chunk_free (ptr_array_mem_chunk, array);
- G_UNLOCK (ptr_array_mem_chunk);
- return segment;
- }
- #include <gmem.c>
- void
- g_free (gpointer mem)
- {
- if (mem)
- glib_mem_vtable.free (mem);
- }
- /* --- variables --- */
- static GMemVTable glib_mem_vtable = {
- standard_malloc,
- standard_realloc,
- standard_free,
- standard_calloc,
- standard_try_malloc,
- standard_try_realloc,
- };
- # define standard_free free
复制代码
g_free也就是调用了标准库的free,该函数位于stdlib.h中,但是我找半天没找到stdlib.c,不知道是不是这样找呢?
小弟初学linux,问的问题让大家见笑了! |
|