[Bf-blender-cvs] [555a83b] hair_system: Macro utility for using MEM_guardedalloc in C++ hair classes.

Lukas Tönne noreply at git.blender.org
Sun Jul 27 17:05:34 CEST 2014


Commit: 555a83bb136b395e01ab1303e18465e75c159021
Author: Lukas Tönne
Date:   Sun Jul 27 12:37:24 2014 +0200
Branches: hair_system
https://developer.blender.org/rB555a83bb136b395e01ab1303e18465e75c159021

Macro utility for using MEM_guardedalloc in C++ hair classes.

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

M	source/blender/hair/CMakeLists.txt
M	source/blender/hair/intern/HAIR_curve.cpp
M	source/blender/hair/intern/HAIR_curve.h
A	source/blender/hair/intern/HAIR_memalloc.h
M	source/blender/hair/intern/HAIR_smoothing.h

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

diff --git a/source/blender/hair/CMakeLists.txt b/source/blender/hair/CMakeLists.txt
index ee0c543..3bcc367 100644
--- a/source/blender/hair/CMakeLists.txt
+++ b/source/blender/hair/CMakeLists.txt
@@ -42,6 +42,7 @@ set(SRC
 
 	intern/HAIR_curve.h
 	intern/HAIR_curve.cpp
+	intern/HAIR_memalloc.h
 	intern/HAIR_smoothing.h
 	intern/HAIR_smoothing.cpp
 	intern/HAIR_types.h
diff --git a/source/blender/hair/intern/HAIR_curve.cpp b/source/blender/hair/intern/HAIR_curve.cpp
index 8d0314b..a5de85d 100644
--- a/source/blender/hair/intern/HAIR_curve.cpp
+++ b/source/blender/hair/intern/HAIR_curve.cpp
@@ -34,8 +34,8 @@ Point::Point(const float3 &co) :
 }
 
 Curve::Curve(int totpoints, Point *points) :
-    totpoints(totpoints),
-    points(points)
+    points(points),
+    totpoints(totpoints)
 {
 }
 
diff --git a/source/blender/hair/intern/HAIR_curve.h b/source/blender/hair/intern/HAIR_curve.h
index 854f612..eb7e32c 100644
--- a/source/blender/hair/intern/HAIR_curve.h
+++ b/source/blender/hair/intern/HAIR_curve.h
@@ -27,6 +27,8 @@
 #ifndef __HAIR_CURVE_H__
 #define __HAIR_CURVE_H__
 
+#include "HAIR_memalloc.h"
+
 #include "HAIR_types.h"
 
 HAIR_NAMESPACE_BEGIN
@@ -35,6 +37,8 @@ class Point {
 	Point(const float3 &co);
 	
 	float3 co;
+	
+	HAIR_CXX_CLASS_ALLOC(Point)
 };
 
 class Curve {
@@ -42,6 +46,8 @@ class Curve {
 	
 	Point *points;
 	int totpoints;
+
+	HAIR_CXX_CLASS_ALLOC(Curve)
 };
 
 HAIR_NAMESPACE_END
diff --git a/source/blender/hair/intern/HAIR_curve.h b/source/blender/hair/intern/HAIR_memalloc.h
similarity index 77%
copy from source/blender/hair/intern/HAIR_curve.h
copy to source/blender/hair/intern/HAIR_memalloc.h
index 854f612..a3cf237 100644
--- a/source/blender/hair/intern/HAIR_curve.h
+++ b/source/blender/hair/intern/HAIR_memalloc.h
@@ -24,26 +24,17 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#ifndef __HAIR_CURVE_H__
-#define __HAIR_CURVE_H__
+#ifndef __HAIR_MEMALLOC_H__
+#define __HAIR_MEMALLOC_H__
 
-#include "HAIR_types.h"
+#include "MEM_guardedalloc.h"
 
-HAIR_NAMESPACE_BEGIN
+#include "BLI_utildefines.h"
 
-class Point {
-	Point(const float3 &co);
-	
-	float3 co;
-};
-
-class Curve {
-	Curve(int totpoints, Point *points);
-	
-	Point *points;
-	int totpoints;
-};
-
-HAIR_NAMESPACE_END
+#ifdef WITH_CXX_GUARDEDALLOC
+	#define HAIR_CXX_CLASS_ALLOC(name) MEM_CXX_CLASS_ALLOC_FUNCS(STRINGIFY(HAIR_NAMESPACE)##name)
+#else
+	#define HAIR_CXX_CLASS_ALLOC(name)
+#endif
 
 #endif
diff --git a/source/blender/hair/intern/HAIR_smoothing.h b/source/blender/hair/intern/HAIR_smoothing.h
index 8504c8d..66be0d8 100644
--- a/source/blender/hair/intern/HAIR_smoothing.h
+++ b/source/blender/hair/intern/HAIR_smoothing.h
@@ -31,6 +31,8 @@ extern "C" {
 #include "BLI_math.h"
 }
 
+#include "HAIR_memalloc.h"
+
 HAIR_NAMESPACE_BEGIN
 
 #if 0
@@ -101,6 +103,8 @@ struct SmoothingIterator {
 	T dval_p, dval_pp;
 	int num;
 	const float beta, f1, f2, f3;
+
+	HAIR_CXX_CLASS_ALLOC(SmoothingIterator)
 };
 
 HAIR_NAMESPACE_END




More information about the Bf-blender-cvs mailing list