CGtkTreeModel/Store内存释放

C GtkTreeModel/Store memory release

例如: 我创建并填充了这样结构的字符串:

然后在代码的某个地方我调用

之后存储在store中的字符串是否会被释放?如果不是,如何从 GtkTreeStoreGtkTreeModel 正确释放内存?

文档对此只字不提。 (或者我找不到信息 :P)

虽然不明确,但文档仍然很清楚:请参阅 gtk_tree_store_set():

The value will be referenced by the store if it is a G_TYPE_OBJECT, and it will be copied if it is a G_TYPE_STRING or G_TYPE_BOXED.

因此 GtkTreeStore 将进行自己的内存管理。实际上,您可以在使用它调用 gtk_tree_store_set*()(或 gtk_tree_store_insert_with_values*())后立即释放您的字符串:此时树存储已经复制了该字符串。