[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r113683: * dispnew.c (glyph_matrix_count, glyph_pool
From: |
Dmitry Antipov |
Subject: |
[Emacs-diffs] trunk r113683: * dispnew.c (glyph_matrix_count, glyph_pool_count): |
Date: |
Sun, 04 Aug 2013 04:09:02 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 113683
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Sun 2013-08-04 08:07:18 +0400
message:
* dispnew.c (glyph_matrix_count, glyph_pool_count):
Move under GLYPH_DEBUG and ENABLE_CHECKING.
(new_glyph_matrix, free_glyph_matrix, new_glyph_pool)
(free_glyph_pool, check_glyph_memory): Likewise for
all users. Adjust comments where appropriate.
modified:
src/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1438
src/dispnew.c dispnew.c-20091113204419-o5vbwnq5f7feedwu-258
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2013-08-03 21:09:57 +0000
+++ b/src/ChangeLog 2013-08-04 04:07:18 +0000
@@ -1,3 +1,11 @@
+2013-08-04 Dmitry Antipov <address@hidden>
+
+ * dispnew.c (glyph_matrix_count, glyph_pool_count):
+ Move under GLYPH_DEBUG and ENABLE_CHECKING.
+ (new_glyph_matrix, free_glyph_matrix, new_glyph_pool)
+ (free_glyph_pool, check_glyph_memory): Likewise for
+ all users. Adjust comments where appropriate.
+
2013-08-03 Paul Eggert <address@hidden>
* composite.h: Minor fixups.
=== modified file 'src/dispnew.c'
--- a/src/dispnew.c 2013-07-23 08:08:57 +0000
+++ b/src/dispnew.c 2013-08-04 04:07:18 +0000
@@ -148,12 +148,16 @@
struct glyph space_glyph;
+#if defined GLYPH_DEBUG && defined ENABLE_CHECKING
+
/* Counts of allocated structures. These counts serve to diagnose
memory leaks and double frees. */
static int glyph_matrix_count;
static int glyph_pool_count;
+#endif /* GLYPH_DEBUG and ENABLE_CHECKING */
+
/* If non-null, the frame whose frame matrices are manipulated. If
null, window matrices are worked on. */
@@ -307,9 +311,11 @@
{
struct glyph_matrix *result = xzalloc (sizeof *result);
+#if defined GLYPH_DEBUG && defined ENABLE_CHECKING
/* Increment number of allocated matrices. This count is used
to detect memory leaks. */
++glyph_matrix_count;
+#endif
/* Set pool and return. */
result->pool = pool;
@@ -319,10 +325,10 @@
/* Free glyph matrix MATRIX. Passing in a null MATRIX is allowed.
- The global counter glyph_matrix_count is decremented when a matrix
- is freed. If the count gets negative, more structures were freed
- than allocated, i.e. one matrix was freed more than once or a bogus
- pointer was passed to this function.
+ If GLYPH_DEBUG and ENABLE_CHECKING are in effect, the global counter
+ glyph_matrix_count is decremented when a matrix is freed. If the count
+ gets negative, more structures were freed than allocated, i.e. one matrix
+ was freed more than once or a bogus pointer was passed to this function.
If MATRIX->pool is null, this means that the matrix manages its own
glyph memory---this is done for matrices on X frames. Freeing the
@@ -335,10 +341,12 @@
{
int i;
+#if defined GLYPH_DEBUG && defined ENABLE_CHECKING
/* Detect the case that more matrices are freed than were
allocated. */
- if (--glyph_matrix_count < 0)
- emacs_abort ();
+ --glyph_matrix_count;
+ eassert (glyph_matrix_count >= 0);
+#endif
/* Free glyph memory if MATRIX owns it. */
if (matrix->pool == NULL)
@@ -1310,38 +1318,41 @@
See dispextern.h for an overall explanation of glyph pools.
***********************************************************************/
-/* Allocate a glyph_pool structure. The structure returned is
- initialized with zeros. The global variable glyph_pool_count is
- incremented for each pool allocated. */
+/* Allocate a glyph_pool structure. The structure returned is initialized
+ with zeros. If GLYPH_DEBUG and ENABLE_CHECKING are in effect, the global
+ variable glyph_pool_count is incremented for each pool allocated. */
static struct glyph_pool *
new_glyph_pool (void)
{
struct glyph_pool *result = xzalloc (sizeof *result);
+#if defined GLYPH_DEBUG && defined ENABLE_CHECKING
/* For memory leak and double deletion checking. */
++glyph_pool_count;
+#endif
return result;
}
/* Free a glyph_pool structure POOL. The function may be called with
- a null POOL pointer. The global variable glyph_pool_count is
- decremented with every pool structure freed. If this count gets
- negative, more structures were freed than allocated, i.e. one
- structure must have been freed more than once or a bogus pointer
- was passed to free_glyph_pool. */
+ a null POOL pointer. If GLYPH_DEBUG and ENABLE_CHECKING are in effect,
+ global variable glyph_pool_count is decremented with every pool structure
+ freed. If this count gets negative, more structures were freed than
+ allocated, i.e. one structure must have been freed more than once or
+ a bogus pointer was passed to free_glyph_pool. */
static void
free_glyph_pool (struct glyph_pool *pool)
{
if (pool)
{
+#if defined GLYPH_DEBUG && defined ENABLE_CHECKING
/* More freed than allocated? */
--glyph_pool_count;
eassert (glyph_pool_count >= 0);
-
+#endif
xfree (pool->glyphs);
xfree (pool);
}
@@ -2254,11 +2265,11 @@
FOR_EACH_FRAME (tail, frame)
free_glyphs (XFRAME (frame));
+#if defined GLYPH_DEBUG && defined ENABLE_CHECKING
/* Check that nothing is left allocated. */
- if (glyph_matrix_count)
- emacs_abort ();
- if (glyph_pool_count)
- emacs_abort ();
+ eassert (glyph_matrix_count == 0);
+ eassert (glyph_pool_count == 0);
+#endif
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r113683: * dispnew.c (glyph_matrix_count, glyph_pool_count):,
Dmitry Antipov <=