Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
45f7a4fc
Commit
45f7a4fc
authored
Dec 26, 2011
by
Hisham Muhammad
Browse files
Remove old memory debugging routines. We have Valgrind nowadays.
parent
84281bdc
Changes
41
Hide whitespace changes
Inline
Side-by-side
AffinityPanel.c
View file @
45f7a4fc
...
...
@@ -8,7 +8,6 @@ in the source distribution for its full text.
#include "AffinityPanel.h"
#include "CheckItem.h"
#include "debug.h"
#include <assert.h>
#include <string.h>
...
...
AvailableColumnsPanel.c
View file @
45f7a4fc
...
...
@@ -9,7 +9,6 @@ in the source distribution for its full text.
#include "Header.h"
#include "ColumnsPanel.h"
#include "debug.h"
#include <assert.h>
#include <stdlib.h>
...
...
AvailableMetersPanel.c
View file @
45f7a4fc
...
...
@@ -10,7 +10,6 @@ in the source distribution for its full text.
#include "CPUMeter.h"
#include "Header.h"
#include "ListItem.h"
#include "debug.h"
#include <assert.h>
#include <stdlib.h>
...
...
BatteryMeter.c
View file @
45f7a4fc
...
...
@@ -12,7 +12,6 @@ This meter written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com).
#include "ProcessList.h"
#include "CRT.h"
#include "String.h"
#include "debug.h"
#include <string.h>
#include <stdlib.h>
...
...
CPUMeter.c
View file @
45f7a4fc
...
...
@@ -9,7 +9,6 @@ in the source distribution for its full text.
#include "CRT.h"
#include "ProcessList.h"
#include "debug.h"
#include <assert.h>
#include <stdlib.h>
...
...
CRT.c
View file @
45f7a4fc
...
...
@@ -9,7 +9,6 @@ in the source distribution for its full text.
#include "config.h"
#include "String.h"
#include "debug.h"
#include <curses.h>
#include <signal.h>
...
...
CategoriesPanel.c
View file @
45f7a4fc
...
...
@@ -13,7 +13,6 @@ in the source distribution for its full text.
#include "ColumnsPanel.h"
#include "ColorsPanel.h"
#include "AvailableColumnsPanel.h"
#include "debug.h"
#include <assert.h>
#include <stdlib.h>
...
...
CheckItem.c
View file @
45f7a4fc
...
...
@@ -8,7 +8,6 @@ in the source distribution for its full text.
#include "CheckItem.h"
#include "CRT.h"
#include "debug.h"
#include <assert.h>
#include <stdlib.h>
...
...
ClockMeter.c
View file @
45f7a4fc
...
...
@@ -8,7 +8,6 @@ in the source distribution for its full text.
#include "ClockMeter.h"
#include "CRT.h"
#include "debug.h"
#include <time.h>
...
...
ColorsPanel.c
View file @
45f7a4fc
...
...
@@ -9,7 +9,6 @@ in the source distribution for its full text.
#include "CRT.h"
#include "CheckItem.h"
#include "debug.h"
#include <assert.h>
#include <stdlib.h>
...
...
ColumnsPanel.c
View file @
45f7a4fc
...
...
@@ -8,7 +8,6 @@ in the source distribution for its full text.
#include "ColumnsPanel.h"
#include "String.h"
#include "debug.h"
#include <assert.h>
#include <stdlib.h>
...
...
DebugMemory.c
deleted
100644 → 0
View file @
84281bdc
/*
htop - DebugMemory.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <assert.h>
#undef strdup
#undef malloc
#undef realloc
#undef calloc
#undef free
#include "DebugMemory.h"
/*{
typedef struct DebugMemoryItem_ DebugMemoryItem;
struct DebugMemoryItem_ {
int magic;
void* data;
char* file;
int line;
DebugMemoryItem* next;
};
typedef struct DebugMemory_ {
DebugMemoryItem* first;
int allocations;
int deallocations;
int size;
bool totals;
FILE* file;
} DebugMemory;
}*/
#if defined(DEBUG)
static
DebugMemory
*
singleton
=
NULL
;
void
DebugMemory_new
()
{
if
(
singleton
)
return
;
singleton
=
malloc
(
sizeof
(
DebugMemory
));
singleton
->
first
=
NULL
;
singleton
->
allocations
=
0
;
singleton
->
deallocations
=
0
;
singleton
->
size
=
0
;
#ifdef DEBUG_ALLOC
singleton
->
file
=
fopen
(
"/tmp/htop-debug-alloc.txt"
,
"w"
);
#else
singleton
->
file
=
NULL
;
#endif
singleton
->
totals
=
true
;
//singleton->file = NULL;
}
void
*
DebugMemory_malloc
(
int
size
,
char
*
file
,
int
line
,
char
*
str
)
{
void
*
data
=
malloc
(
size
);
DebugMemory_registerAllocation
(
data
,
file
,
line
);
if
(
singleton
->
file
)
{
if
(
singleton
->
totals
)
fprintf
(
singleton
->
file
,
"%d
\t
"
,
singleton
->
size
);
fprintf
(
singleton
->
file
,
"%d
\t
%s:%d (%s)
\n
"
,
size
,
file
,
line
,
str
);
}
return
data
;
}
void
*
DebugMemory_calloc
(
int
a
,
int
b
,
char
*
file
,
int
line
)
{
void
*
data
=
calloc
(
a
,
b
);
DebugMemory_registerAllocation
(
data
,
file
,
line
);
if
(
singleton
->
file
)
{
if
(
singleton
->
totals
)
fprintf
(
singleton
->
file
,
"%d
\t
"
,
singleton
->
size
);
fprintf
(
singleton
->
file
,
"%d
\t
%s:%d
\n
"
,
a
*
b
,
file
,
line
);
}
return
data
;
}
void
*
DebugMemory_realloc
(
void
*
ptr
,
int
size
,
char
*
file
,
int
line
,
char
*
str
)
{
if
(
ptr
!=
NULL
)
DebugMemory_registerDeallocation
(
ptr
,
file
,
line
);
void
*
data
=
realloc
(
ptr
,
size
);
DebugMemory_registerAllocation
(
data
,
file
,
line
);
if
(
singleton
->
file
)
{
if
(
singleton
->
totals
)
fprintf
(
singleton
->
file
,
"%d
\t
"
,
singleton
->
size
);
fprintf
(
singleton
->
file
,
"%d
\t
%s:%d (%s)
\n
"
,
size
,
file
,
line
,
str
);
}
return
data
;
}
void
*
DebugMemory_strdup
(
const
char
*
str
,
char
*
file
,
int
line
)
{
assert
(
str
);
char
*
data
=
strdup
(
str
);
DebugMemory_registerAllocation
(
data
,
file
,
line
);
if
(
singleton
->
file
)
{
if
(
singleton
->
totals
)
fprintf
(
singleton
->
file
,
"%d
\t
"
,
singleton
->
size
);
fprintf
(
singleton
->
file
,
"%d
\t
%s:%d
\n
"
,
(
int
)
strlen
(
str
),
file
,
line
);
}
return
data
;
}
void
DebugMemory_free
(
void
*
data
,
char
*
file
,
int
line
)
{
if
(
!
data
)
return
;
DebugMemory_registerDeallocation
(
data
,
file
,
line
);
if
(
singleton
->
file
)
{
if
(
singleton
->
totals
)
fprintf
(
singleton
->
file
,
"%d
\t
"
,
singleton
->
size
);
fprintf
(
singleton
->
file
,
"free
\t
%s:%d
\n
"
,
file
,
line
);
}
free
(
data
);
}
void
DebugMemory_assertSize
()
{
if
(
!
singleton
->
first
)
{
assert
(
singleton
->
size
==
0
);
}
DebugMemoryItem
*
walk
=
singleton
->
first
;
int
i
=
0
;
while
(
walk
!=
NULL
)
{
assert
(
walk
->
magic
==
11061980
);
i
++
;
walk
=
walk
->
next
;
}
assert
(
i
==
singleton
->
size
);
}
int
DebugMemory_getBlockCount
()
{
if
(
!
singleton
->
first
)
{
return
0
;
}
DebugMemoryItem
*
walk
=
singleton
->
first
;
int
i
=
0
;
while
(
walk
!=
NULL
)
{
assert
(
walk
->
magic
==
11061980
);
i
++
;
walk
=
walk
->
next
;
}
return
i
;
}
void
DebugMemory_registerAllocation
(
void
*
data
,
char
*
file
,
int
line
)
{
if
(
!
singleton
)
DebugMemory_new
();
DebugMemory_assertSize
();
DebugMemoryItem
*
item
=
(
DebugMemoryItem
*
)
malloc
(
sizeof
(
DebugMemoryItem
));
item
->
magic
=
11061980
;
item
->
data
=
data
;
item
->
file
=
file
;
item
->
line
=
line
;
item
->
next
=
NULL
;
int
val
=
DebugMemory_getBlockCount
();
if
(
singleton
->
first
==
NULL
)
{
assert
(
val
==
0
);
singleton
->
first
=
item
;
}
else
{
DebugMemoryItem
*
walk
=
singleton
->
first
;
while
(
true
)
{
if
(
walk
->
next
==
NULL
)
{
walk
->
next
=
item
;
break
;
}
assert
(
walk
->
magic
==
11061980
);
walk
=
walk
->
next
;
}
}
int
nval
=
DebugMemory_getBlockCount
();
assert
(
nval
==
val
+
1
);
singleton
->
allocations
++
;
singleton
->
size
++
;
DebugMemory_assertSize
();
}
void
DebugMemory_registerDeallocation
(
void
*
data
,
char
*
file
,
int
line
)
{
assert
(
singleton
);
assert
(
singleton
->
first
);
DebugMemoryItem
*
walk
=
singleton
->
first
;
DebugMemoryItem
*
prev
=
NULL
;
int
val
=
DebugMemory_getBlockCount
();
while
(
walk
!=
NULL
)
{
assert
(
walk
->
magic
==
11061980
);
if
(
walk
->
data
==
data
)
{
if
(
prev
==
NULL
)
{
singleton
->
first
=
walk
->
next
;
}
else
{
prev
->
next
=
walk
->
next
;
}
free
(
walk
);
assert
(
DebugMemory_getBlockCount
()
==
val
-
1
);
singleton
->
deallocations
++
;
singleton
->
size
--
;
DebugMemory_assertSize
();
return
;
}
DebugMemoryItem
*
tmp
=
walk
;
walk
=
walk
->
next
;
prev
=
tmp
;
}
DebugMemory_report
();
fprintf
(
stderr
,
"Couldn't find allocation for memory freed at %s:%d
\n
"
,
file
,
line
);
assert
(
false
);
}
void
DebugMemory_report
()
{
assert
(
singleton
);
DebugMemoryItem
*
walk
=
singleton
->
first
;
int
i
=
0
;
while
(
walk
!=
NULL
)
{
assert
(
walk
->
magic
==
11061980
);
i
++
;
fprintf
(
stderr
,
"%p %s:%d
\n
"
,
walk
->
data
,
walk
->
file
,
walk
->
line
);
DebugMemoryItem
*
old
=
walk
;
walk
=
walk
->
next
;
free
(
old
->
file
);
free
(
old
);
}
fprintf
(
stderr
,
"Total:
\n
"
);
fprintf
(
stderr
,
"%d allocations
\n
"
,
singleton
->
allocations
);
fprintf
(
stderr
,
"%d deallocations
\n
"
,
singleton
->
deallocations
);
fprintf
(
stderr
,
"%d size
\n
"
,
singleton
->
size
);
fprintf
(
stderr
,
"%d non-freed blocks
\n
"
,
i
);
if
(
singleton
->
file
)
fclose
(
singleton
->
file
);
free
(
singleton
);
}
#elif defined(DEBUGLITE)
//#include "efence.h"
#endif
DebugMemory.h
deleted
100644 → 0
View file @
84281bdc
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_DebugMemory
#define HEADER_DebugMemory
/*
htop - DebugMemory.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
#undef strdup
#undef malloc
#undef realloc
#undef calloc
#undef free
typedef
struct
DebugMemoryItem_
DebugMemoryItem
;
struct
DebugMemoryItem_
{
int
magic
;
void
*
data
;
char
*
file
;
int
line
;
DebugMemoryItem
*
next
;
};
typedef
struct
DebugMemory_
{
DebugMemoryItem
*
first
;
int
allocations
;
int
deallocations
;
int
size
;
bool
totals
;
FILE
*
file
;
}
DebugMemory
;
#if defined(DEBUG)
void
DebugMemory_new
();
void
*
DebugMemory_malloc
(
int
size
,
char
*
file
,
int
line
,
char
*
str
);
void
*
DebugMemory_calloc
(
int
a
,
int
b
,
char
*
file
,
int
line
);
void
*
DebugMemory_realloc
(
void
*
ptr
,
int
size
,
char
*
file
,
int
line
,
char
*
str
);
void
*
DebugMemory_strdup
(
const
char
*
str
,
char
*
file
,
int
line
);
void
DebugMemory_free
(
void
*
data
,
char
*
file
,
int
line
);
void
DebugMemory_assertSize
();
int
DebugMemory_getBlockCount
();
void
DebugMemory_registerAllocation
(
void
*
data
,
char
*
file
,
int
line
);
void
DebugMemory_registerDeallocation
(
void
*
data
,
char
*
file
,
int
line
);
void
DebugMemory_report
();
#elif defined(DEBUGLITE)
//#include "efence.h"
#endif
#endif
DisplayOptionsPanel.c
View file @
45f7a4fc
...
...
@@ -8,7 +8,6 @@ in the source distribution for its full text.
#include "DisplayOptionsPanel.h"
#include "CheckItem.h"
#include "debug.h"
#include <assert.h>
#include <stdlib.h>
...
...
FunctionBar.c
View file @
45f7a4fc
...
...
@@ -8,7 +8,6 @@ in the source distribution for its full text.
#include "FunctionBar.h"
#include "CRT.h"
#include "debug.h"
#include <assert.h>
#include <string.h>
...
...
Hashtable.c
View file @
45f7a4fc
...
...
@@ -7,8 +7,6 @@ in the source distribution for its full text.
#include "Hashtable.h"
#include "debug.h"
#include <stdlib.h>
#include <assert.h>
...
...
Header.c
View file @
45f7a4fc
...
...
@@ -18,7 +18,6 @@ in the source distribution for its full text.
#include "ClockMeter.h"
#include "HostnameMeter.h"
#include "String.h"
#include "debug.h"
#include <assert.h>
#include <time.h>
...
...
HostnameMeter.c
View file @
45f7a4fc
...
...
@@ -8,7 +8,6 @@ in the source distribution for its full text.
#include "HostnameMeter.h"
#include "CRT.h"
#include "debug.h"
#include <unistd.h>
...
...
ListItem.c
View file @
45f7a4fc
...
...
@@ -10,7 +10,6 @@ in the source distribution for its full text.
#include "CRT.h"
#include "String.h"
#include "RichString.h"
#include "debug.h"
#include <string.h>
#include <assert.h>
...
...
LoadAverageMeter.c
View file @
45f7a4fc
...
...
@@ -8,7 +8,6 @@ in the source distribution for its full text.
#include "LoadAverageMeter.h"
#include "CRT.h"
#include "debug.h"
#include <curses.h>
#include <assert.h>
...
...
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment