[Bf-blender-cvs] [1e6ad49dca6] master: Add utility function to free memory used by a datablock

Sergey Sharybin noreply at git.blender.org
Wed Jun 14 10:46:35 CEST 2017


Commit: 1e6ad49dca6145c61c94a3e196526edd9b6459d4
Author: Sergey Sharybin
Date:   Wed Jun 14 10:45:20 2017 +0200
Branches: master
https://developer.blender.org/rB1e6ad49dca6145c61c94a3e196526edd9b6459d4

Add utility function to free memory used by a datablock

This function is similar to BKE_libblock_free but does no DEG
tagging or any extra things, just operates on memory.

===================================================================

M	source/blender/blenkernel/BKE_library.h
M	source/blender/blenkernel/intern/library_remap.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index e74f33d9260..f1c0563b731 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -65,6 +65,7 @@ struct ID *BKE_libblock_find_name(const short type, const char *name) ATTR_WARN_
 
 /* library_remap.c (keep here since they're general functions) */
 void  BKE_libblock_free(struct Main *bmain, void *idv) ATTR_NONNULL();
+void BKE_libblock_free_datablock(struct ID *id) ATTR_NONNULL();
 void  BKE_libblock_free_ex(struct Main *bmain, void *idv, const bool do_id_user, const bool do_ui_user) ATTR_NONNULL();
 void  BKE_libblock_free_us(struct Main *bmain, void *idv) ATTR_NONNULL();
 void  BKE_libblock_free_data(struct Main *bmain, struct ID *id, const bool do_id_user) ATTR_NONNULL();
diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c
index 24626c6ead7..668962cf6e4 100644
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@ -731,30 +731,9 @@ void BKE_libblock_free_data(Main *UNUSED(bmain), ID *id, const bool do_id_user)
 	}
 }
 
-/**
- * used in headerbuttons.c image.c mesh.c screen.c sound.c and library.c
- *
- * \param do_id_user: if \a true, try to release other ID's 'references' hold by \a idv.
- *                    (only applies to main database)
- * \param do_ui_user: similar to do_id_user but makes sure UI does not hold references to
- *                    \a id.
- */
-void BKE_libblock_free_ex(Main *bmain, void *idv, const bool do_id_user, const bool do_ui_user)
+void BKE_libblock_free_datablock(ID *id)
 {
-	ID *id = idv;
-	short type = GS(id->name);
-	ListBase *lb = which_libbase(bmain, type);
-
-	DAG_id_type_tag(bmain, type);
-
-#ifdef WITH_PYTHON
-	BPY_id_release(id);
-#endif
-
-	if (do_id_user) {
-		BKE_libblock_relink_ex(bmain, id, NULL, NULL, true);
-	}
-
+	const short type = GS(id->name);
 	switch (type) {
 		case ID_SCE:
 			BKE_scene_free((Scene *)id);
@@ -860,6 +839,33 @@ void BKE_libblock_free_ex(Main *bmain, void *idv, const bool do_id_user, const b
 			BKE_cachefile_free((CacheFile *)id);
 			break;
 	}
+}
+
+/**
+ * used in headerbuttons.c image.c mesh.c screen.c sound.c and library.c
+ *
+ * \param do_id_user: if \a true, try to release other ID's 'references' hold by \a idv.
+ *                    (only applies to main database)
+ * \param do_ui_user: similar to do_id_user but makes sure UI does not hold references to
+ *                    \a id.
+ */
+void BKE_libblock_free_ex(Main *bmain, void *idv, const bool do_id_user, const bool do_ui_user)
+{
+	ID *id = idv;
+	short type = GS(id->name);
+	ListBase *lb = which_libbase(bmain, type);
+
+	DAG_id_type_tag(bmain, type);
+
+#ifdef WITH_PYTHON
+	BPY_id_release(id);
+#endif
+
+	if (do_id_user) {
+		BKE_libblock_relink_ex(bmain, id, NULL, NULL, true);
+	}
+
+	BKE_libblock_free_datablock(id);
 
 	/* avoid notifying on removed data */
 	BKE_main_lock(bmain);




More information about the Bf-blender-cvs mailing list