Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
lyskom-server-ceder-1616-generations-topgit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Per Cederqvist
lyskom-server-ceder-1616-generations-topgit
Commits
2cbfa9be
Commit
2cbfa9be
authored
33 years ago
by
Per Cederqvist
Browse files
Options
Downloads
Patches
Plain Diff
Memory leak hunting utilities.
parent
6752359a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/server/ChangeLog
+10
-0
10 additions, 0 deletions
src/server/ChangeLog
src/server/ram-smalloc.c
+51
-4
51 additions, 4 deletions
src/server/ram-smalloc.c
with
61 additions
and
4 deletions
src/server/ChangeLog
+
10
−
0
View file @
2cbfa9be
Sat Sep 21 02:12:24 1991 Per Cederqvist (ceder at lysator)
Sat Sep 21 02:12:24 1991 Per Cederqvist (ceder at lysator)
* ram-smalloc.c: Added support for memory leak finding.
* trace-mem.gdb, handle-malloc-dump.el: Useful for finding memory
leaks in the server. Compile ram-smalloc.c with DEBUG_MALLOC
defined.
* mux.c (mux_close): Fixed memory leak.
* ramkomd.c (main): Print how many blocks isc allocates.
* ramkomd.c: ip_client_port and ip_mux_port are local to ramkomd.c.
* ramkomd.c: ip_client_port and ip_mux_port are local to ramkomd.c.
Tue Sep 17 23:04:39 1991 Per Cederqvist (ceder at lysator)
Tue Sep 17 23:04:39 1991 Per Cederqvist (ceder at lysator)
...
...
This diff is collapsed.
Click to expand it.
src/server/ram-smalloc.c
+
51
−
4
View file @
2cbfa9be
/*
/*
* $Id: ram-smalloc.c,v 0.
6
1991/09/
15 10:29:31 linus
Exp $
* $Id: ram-smalloc.c,v 0.
7
1991/09/
21 12:19:24 ceder
Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
* Copyright (C) 1991 Lysator Academic Computer Association.
*
*
* This file is part of the LysKOM server.
* This file is part of the LysKOM server.
...
@@ -30,7 +30,14 @@
...
@@ -30,7 +30,14 @@
* TEST VERSION by ceder
* TEST VERSION by ceder
*/
*/
static
char
*
rcsid
=
"$Id: ram-smalloc.c,v 0.6 1991/09/15 10:29:31 linus Exp $"
;
/*
* Define DEBUG_MALLOC to get traces from smalloc, srealloc and sfree.
* Run the resulting lyskomd under gdb. Source trace-mem.gdb. Run
* handle-malloc-dump.el on the resulting output.
*/
/* #define DEBUG_MALLOC */
static
char
*
rcsid
=
"$Id: ram-smalloc.c,v 0.7 1991/09/21 12:19:24 ceder Exp $"
;
#include
<stdio.h>
#include
<stdio.h>
...
@@ -45,6 +52,16 @@ static char *rcsid = "$Id: ram-smalloc.c,v 0.6 1991/09/15 10:29:31 linus Exp $";
...
@@ -45,6 +52,16 @@ static char *rcsid = "$Id: ram-smalloc.c,v 0.6 1991/09/15 10:29:31 linus Exp $";
static
int
no_of_allocated_blocks
=
0
;
static
int
no_of_allocated_blocks
=
0
;
#ifdef DEBUG_MALLOC
static
void
trace_smalloc
(
size_t
size
,
void
*
result
)
{
printf
(
"smalloc:
\n
Arg: 0x%lx
\n
Res: 0x%lx
\n
"
,
(
long
)
size
,
(
long
)
result
);
printf
(
"==== end ====
\n
"
);
}
#endif
/*
/*
* "safe" malloc. Handles the case when malloc returns NULL.
* "safe" malloc. Handles the case when malloc returns NULL.
* smalloc cannot fail.
* smalloc cannot fail.
...
@@ -65,9 +82,21 @@ smalloc(size_t size)
...
@@ -65,9 +82,21 @@ smalloc(size_t size)
((
unsigned
char
*
)
p
)[
size
]
=
0x89
;
((
unsigned
char
*
)
p
)[
size
]
=
0x89
;
((
unsigned
char
*
)
p
)[
size
+
1
]
=
0xA7
;
((
unsigned
char
*
)
p
)[
size
+
1
]
=
0xA7
;
#ifdef DEBUG_MALLOC
trace_smalloc
(
size
,
p
);
#endif
return
(
void
*
)
p
;
return
(
void
*
)
p
;
}
}
#ifdef DEBUG_MALLOC
static
void
trace_free
(
void
*
block
)
{
printf
(
"sfree:
\n
Arg: 0x%lx
\n
"
,
(
long
)
block
);
printf
(
"==== end ====
\n
"
);
}
#endif
EXPORT
void
EXPORT
void
sfree
(
void
*
ptr
)
/* it is legal to sfree a NULL pointer */
sfree
(
void
*
ptr
)
/* it is legal to sfree a NULL pointer */
...
@@ -81,6 +110,9 @@ sfree(void * ptr) /* it is legal to sfree a NULL pointer */
...
@@ -81,6 +110,9 @@ sfree(void * ptr) /* it is legal to sfree a NULL pointer */
if
(
ptr
!=
NULL
)
if
(
ptr
!=
NULL
)
{
{
#ifdef DEBUG_MALLOC
trace_free
(
ptr
);
#endif
ip
=
(
unsigned
int
*
)
ptr
;
ip
=
(
unsigned
int
*
)
ptr
;
ip
-=
2
;
ip
-=
2
;
switch
(
*
ip
)
switch
(
*
ip
)
...
@@ -103,6 +135,17 @@ sfree(void * ptr) /* it is legal to sfree a NULL pointer */
...
@@ -103,6 +135,17 @@ sfree(void * ptr) /* it is legal to sfree a NULL pointer */
}
}
}
}
#ifdef DEBUG_MALLOC
static
void
trace_srealloc
(
size_t
size
,
void
*
arg
,
void
*
result
)
{
printf
(
"srealloc:
\n
Size: 0x%lx
\n
Arg: 0x%lx
\n
Res: 0x%lx
\n
"
,
(
long
)
size
,
(
long
)
arg
,
(
long
)
result
);
printf
(
"==== end ====
\n
"
);
}
#endif
EXPORT
void
*
EXPORT
void
*
srealloc
(
void
*
ptr
,
size_t
size
)
/* Never fails. It is legal to */
srealloc
(
void
*
ptr
,
size_t
size
)
/* Never fails. It is legal to */
{
/* realloc the NULL ptr. */
{
/* realloc the NULL ptr. */
...
@@ -145,6 +188,10 @@ srealloc(void * ptr, size_t size) /* Never fails. It is legal to */
...
@@ -145,6 +188,10 @@ srealloc(void * ptr, size_t size) /* Never fails. It is legal to */
((
unsigned
char
*
)
new_ptr
)[
size
]
=
0x89
;
((
unsigned
char
*
)
new_ptr
)[
size
]
=
0x89
;
((
unsigned
char
*
)
new_ptr
)[
size
+
1
]
=
0xA7
;
((
unsigned
char
*
)
new_ptr
)[
size
+
1
]
=
0xA7
;
#ifdef DEBUG_MALLOC
trace_srealloc
(
size
,
ptr
,
new_ptr
);
#endif
return
(
void
*
)
new_ptr
;
return
(
void
*
)
new_ptr
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment