[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] anuj-distance-field 00eb740 58/95: [sdf] Added total memory
From: |
Anuj Verma |
Subject: |
[freetype2] anuj-distance-field 00eb740 58/95: [sdf] Added total memory allocation log. |
Date: |
Sun, 2 Aug 2020 01:10:36 -0400 (EDT) |
branch: anuj-distance-field
commit 00eb740cf179e17739044a92bcd743b63ca17620
Author: Anuj Verma <anujv@iitbhilai.ac.in>
Commit: Anuj Verma <anujv@iitbhilai.ac.in>
[sdf] Added total memory allocation log.
* src/sdf/ftsdf.c (*): Replaced `FT_QNEW' and `FT_ALLOC_MULT'
to custom macros in order to track memory allocations
throughout the process of generating SDF. It basically
add the memory being allocated to a static global variable
and at the end outputs it at the end.
---
[GSoC]ChangeLog | 10 ++++++++++
src/sdf/ftsdf.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 60 insertions(+), 4 deletions(-)
diff --git a/[GSoC]ChangeLog b/[GSoC]ChangeLog
index 120215b..8f1187c 100644
--- a/[GSoC]ChangeLog
+++ b/[GSoC]ChangeLog
@@ -1,3 +1,13 @@
+2020-07-16 Anuj Verma <anujv@iitbhilai.ac.in>
+
+ [sdf] Added total memory allocation log.
+
+ * src/sdf/ftsdf.c (*): Replaced `FT_QNEW' and `FT_ALLOC_MULT'
+ to custom macros in order to track memory allocations
+ throughout the process of generating SDF. It basically
+ add the memory being allocated to a static global variable
+ and at the end outputs it at the end.
+
2020-07-15 Anuj Verma <anujv@iitbhilai.ac.in>
* src/sdf/ftsdfrend.c (sdf_property_set): Minor fix.
diff --git a/src/sdf/ftsdf.c b/src/sdf/ftsdf.c
index f8e6f60..15d5648 100644
--- a/src/sdf/ftsdf.c
+++ b/src/sdf/ftsdf.c
@@ -8,6 +8,48 @@
/**************************************************************************
*
+ * macros to track intermediate memory allocations
+ *
+ */
+
+#ifdef FT_DEBUG_LEVEL_TRACE
+
+ /* These macros are used to track and output the total */
+ /* memory allocation once the SDF is generated. */
+
+ static FT_Long s_total_memory_allocated;
+
+ #define SDF_MEM_TRACK_START() s_total_memory_allocated = 0
+
+ #define SDF_MEM_TRACK_END() \
+ FT_TRACE0(( "[sdf] Total intermediate memory allocated = " \
+ "%ld bytes\n", s_total_memory_allocated )); \
+ s_total_memory_allocated = 0
+
+ /* We only use these two macros to allocate memory in */
+ /* the module. */
+
+ #define SDF_ALLOC_MULT( ptr, count, item_size ) \
+ s_total_memory_allocated += count * item_size, \
+ FT_ALLOC_MULT( ptr, count, item_size )
+
+ #define SDF_QNEW( ptr ) \
+ s_total_memory_allocated += sizeof( *ptr ), \
+ !FT_QNEW( ptr )
+#else
+
+ #define SDF_MEM_TRACK_START()
+ #define SDF_MEM_TRACK_END()
+
+ #define SDF_ALLOC_MULT( ptr, count, item_size ) \
+ FT_ALLOC_MULT( ptr, count, item_size )
+
+ #define SDF_QNEW( ptr ) !FT_QNEW( ptr )
+
+#endif
+
+ /**************************************************************************
+ *
* definitions
*
*/
@@ -237,7 +279,7 @@
goto Exit;
}
- if ( !FT_QNEW( ptr ) )
+ if ( SDF_QNEW( ptr ) )
{
*ptr = null_edge;
*edge = ptr;
@@ -274,7 +316,7 @@
goto Exit;
}
- if ( !FT_QNEW( ptr ) )
+ if ( SDF_QNEW( ptr ) )
{
*ptr = null_contour;
*contour = ptr;
@@ -326,7 +368,7 @@
goto Exit;
}
- if ( !FT_QNEW( ptr ) )
+ if ( SDF_QNEW( ptr ) )
{
*ptr = null_shape;
ptr->memory = memory;
@@ -2589,7 +2631,7 @@
rows = bitmap->rows;
buffer = (FT_Short*)bitmap->buffer;
- if ( FT_ALLOC_MULT( dists, width, rows * sizeof(*dists) ) )
+ if ( SDF_ALLOC_MULT( dists, width, rows * sizeof(*dists) ) )
goto Exit;
FT_MEM_ZERO( dists, width * rows * sizeof(*dists) );
@@ -3067,6 +3109,8 @@
SDF_Params internal_params;
+ SDF_MEM_TRACK_START();
+
/* check for valid arguments */
if ( !sdf_raster || !sdf_params )
{
@@ -3150,6 +3194,8 @@
if ( shape )
sdf_shape_done( &shape );
+ SDF_MEM_TRACK_END();
+
Exit:
return error;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] anuj-distance-field 00eb740 58/95: [sdf] Added total memory allocation log.,
Anuj Verma <=