//file: example02.c #include<glib-object.h> staticvoidshow_ref_count(GObject *instance) { if (G_IS_OBJECT (instance)) /* Users should not use ref_count member in their program. */ /* This is only for demonstration. */ g_print ("Reference count is %d.\n", instance->ref_count); else g_print ("Instance is not GObject.\n"); } intmain(int argc, char **argv) { GObject *instance;
instance = g_object_new (G_TYPE_OBJECT, NULL); g_print ("Call g_object_new.\n"); show_ref_count (instance); g_object_ref (instance); g_print ("Call g_object_ref.\n"); show_ref_count (instance); g_object_unref (instance); g_print ("Call g_object_unref.\n"); show_ref_count (instance); g_object_unref (instance); g_print ("Call g_object_unref.\n"); g_print ("Now the reference count is zero and the instance is destroyed.\n"); g_print ("The instance memories are possibly returned to the system.\n"); g_print ("Therefore, the access to the same address may cause a segmentation error.\n");
//file: example02.c #include<glib-object.h> staticvoidshow_ref_count(GObject* instance) { if (G_IS_OBJECT (instance)) /* Users should not use ref_count member in their program. */ /* This is only for demonstration. */ g_print ("Reference count is %d.\n", instance->ref_count); else g_print ("Instance is not GObject.\n"); } intmain(int argc, char **argv) { GObject* instance;
instance = g_object_new (G_TYPE_OBJECT, NULL); g_print ("Call g_object_new.\n"); show_ref_count (instance); g_object_ref (instance); g_print ("Call g_object_ref.\n"); show_ref_count (instance); g_object_unref (instance); g_print ("Call g_object_unref.\n"); show_ref_count (instance); g_object_unref (instance); g_print ("Call g_object_unref.\n"); g_print ("Now the reference count is zero and the instance is destroyed.\n"); g_print ("The instance memories are possibly returned to the system.\n"); g_print ("Therefore, the access to the same address may cause a segmentation error.\n");
dtype = paw_double_get_type(); /* or dtype = PAW_TYPE_DOUBLE */ if(dtype) g_print("Registration was a success. The type is %lx.\n", dtype); else g_print("Registration failed.\n");
d = g_object_new(PAW_TYPE_DOUBLE, NULL); if(d) g_print("Instantiation was a success. The instance address is %p.\n", d); else g_print("Instantiation failed.\n"); g_object_unref(d); /* Releases the object d. */
dtype = paw_double_get_type(); /* or dtype = PAW_TYPE_DOUBLE */ if(dtype) g_print("Registration was a success. The type is %lx.\n", dtype); else g_print("Registration failed.\n");
d = g_object_new(PAW_TYPE_DOUBLE, NULL); if(d) g_print("Instantiation was a success. The instance address is %p.\n", d); else g_print("Instantiation failed.\n"); g_object_unref(d); /* Releases the object d. */
//file: example02.c #include<glib-object.h> staticvoidshow_ref_count(GObject *instance) { if (G_IS_OBJECT (instance)) /* Users should not use ref_count member in their program. */ /* This is only for demonstration. */ g_print ("Reference count is %d.\n", instance->ref_count); else g_print ("Instance is not GObject.\n"); } intmain(int argc, char **argv) { GObject *instance;
instance = g_object_new (G_TYPE_OBJECT, NULL); g_print ("Call g_object_new.\n"); show_ref_count (instance); g_object_ref (instance); g_print ("Call g_object_ref.\n"); show_ref_count (instance); g_object_unref (instance); g_print ("Call g_object_unref.\n"); show_ref_count (instance); g_object_unref (instance); g_print ("Call g_object_unref.\n"); g_print ("Now the reference count is zero and the instance is destroyed.\n"); g_print ("The instance memories are possibly returned to the system.\n"); g_print ("Therefore, the access to the same address may cause a segmentation error.\n");
return0; }
+
//file: example02.c #include<glib-object.h> staticvoidshow_ref_count(GObject* instance) { if (G_IS_OBJECT (instance)) /* Users should not use ref_count member in their program. */ /* This is only for demonstration. */ g_print ("Reference count is %d.\n", instance->ref_count); else g_print ("Instance is not GObject.\n"); } intmain(int argc, char **argv) { GObject* instance;
instance = g_object_new (G_TYPE_OBJECT, NULL); g_print ("Call g_object_new.\n"); show_ref_count (instance); g_object_ref (instance); g_print ("Call g_object_ref.\n"); show_ref_count (instance); g_object_unref (instance); g_print ("Call g_object_unref.\n"); show_ref_count (instance); g_object_unref (instance); g_print ("Call g_object_unref.\n"); g_print ("Now the reference count is zero and the instance is destroyed.\n"); g_print ("The instance memories are possibly returned to the system.\n"); g_print ("Therefore, the access to the same address may cause a segmentation error.\n");
dtype = paw_double_get_type(); /* or dtype = PAW_TYPE_DOUBLE */ if(dtype) g_print("Registration was a success. The type is %lx.\n", dtype); else g_print("Registration failed.\n");
d = g_object_new(PAW_TYPE_DOUBLE, NULL); if(d) g_print("Instantiation was a success. The instance address is %p.\n", d); else g_print("Instantiation failed.\n"); g_object_unref(d); /* Releases the object d. */
dtype = paw_double_get_type(); /* or dtype = PAW_TYPE_DOUBLE */ if(dtype) g_print("Registration was a success. The type is %lx.\n", dtype); else g_print("Registration failed.\n");
d = g_object_new(PAW_TYPE_DOUBLE, NULL); if(d) g_print("Instantiation was a success. The instance address is %p.\n", d); else g_print("Instantiation failed.\n"); g_object_unref(d); /* Releases the object d. */
dtype = paw_double_get_type(); /* or dtype = PAW_TYPE_DOUBLE */ if(dtype) g_print("Registration was a success. The type is %lx.\n", dtype); else g_print("Registration failed.\n");
d = g_object_new(PAW_TYPE_DOUBLE, NULL); if(d) g_print("Instantiation was a success. The instance address is %p.\n", d); else g_print("Instantiation failed.\n"); g_object_unref(d);
dtype = paw_double_get_type(); /* or dtype = PAW_TYPE_DOUBLE */ if(dtype) g_print("Registration was a success. The type is %lx.\n", dtype); else g_print("Registration failed.\n");
d = g_object_new(PAW_TYPE_DOUBLE, NULL); if(d) g_print("Instantiation was a success. The instance address is %p.\n", d); else g_print("Instantiation failed.\n"); g_object_unref(d);
- 共撰写了 39 篇文章 + 共撰写了 40 篇文章 - 共 47.2k 字 + 共 50.6k 字
diff --git "a/categories/\345\267\245\344\270\232\347\233\270\346\234\272/Aravis/index.html" "b/categories/\345\267\245\344\270\232\347\233\270\346\234\272/Aravis/index.html" index 1a1a3a2..faf65ba 100644 --- "a/categories/\345\267\245\344\270\232\347\233\270\346\234\272/Aravis/index.html" +++ "b/categories/\345\267\245\344\270\232\347\233\270\346\234\272/Aravis/index.html" @@ -476,11 +476,11 @@