Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
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
pikelang
pike
Commits
52654cda
Commit
52654cda
authored
27 years ago
by
Fredrik Hübinette (Hubbe)
Browse files
Options
Downloads
Patches
Plain Diff
bugfixes in DEBUG_MALLOC
Rev: src/pike_memory.c:1.23
parent
c0988f63
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pike_memory.c
+18
-10
18 additions, 10 deletions
src/pike_memory.c
with
18 additions
and
10 deletions
src/pike_memory.c
+
18
−
10
View file @
52654cda
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#include
"pike_macros.h"
#include
"pike_macros.h"
#include
"gc.h"
#include
"gc.h"
RCSID
(
"$Id: pike_memory.c,v 1.2
2
1998/04/1
6 21:30:0
9 hubbe Exp $"
);
RCSID
(
"$Id: pike_memory.c,v 1.2
3
1998/04/1
7 17:17:3
9 hubbe Exp $"
);
/* strdup() is used by several modules, so let's provide it */
/* strdup() is used by several modules, so let's provide it */
#ifndef HAVE_STRDUP
#ifndef HAVE_STRDUP
...
@@ -466,10 +466,13 @@ int verbose_debug_exit = 1;
...
@@ -466,10 +466,13 @@ int verbose_debug_exit = 1;
#define LHSIZE 1109891
#define LHSIZE 1109891
#define FLSIZE 8803
#define FLSIZE 8803
#define DEBUG_MALLOC_PAD 8
#define DEBUG_MALLOC_PAD 8
#define FREE_DELAY 256
#define FREE_DELAY 1024
#define MAX_UNFREE_MEM 1024*1024*16
static
void
*
blocks_to_free
[
FREE_DELAY
];
static
void
*
blocks_to_free
[
FREE_DELAY
];
static
unsigned
int
blocks_to_free_ptr
=
0
;
static
unsigned
int
blocks_to_free_ptr
=
0
;
static
unsigned
long
unfree_mem
=
0
;
static
int
exiting
=
0
;
struct
fileloc
struct
fileloc
{
{
...
@@ -831,11 +834,13 @@ void debug_free(void *p, const char *fn, int line)
...
@@ -831,11 +834,13 @@ void debug_free(void *p, const char *fn, int line)
mt_lock
(
&
debug_malloc_mutex
);
mt_lock
(
&
debug_malloc_mutex
);
if
(
verbose_debug_malloc
)
if
(
verbose_debug_malloc
)
fprintf
(
stderr
,
"free(%p) (%s:%d)
\n
"
,
p
,
fn
,
line
);
fprintf
(
stderr
,
"free(%p) (%s:%d)
\n
"
,
p
,
fn
,
line
);
if
((
mh
=
find_memhdr
(
p
)))
if
(
!
exiting
&&
(
mh
=
find_memhdr
(
p
)))
{
{
void
*
p2
;
void
*
p2
;
add_location
(
mh
,
location_number
(
fn
,
line
));
MEMSET
(
p
,
0x55
,
mh
->
size
);
MEMSET
(
p
,
0x55
,
mh
->
size
);
if
(
mh
->
size
<
MAX_UNFREE_MEM
/
FREE_DELAY
)
{
add_location
(
mh
,
location_number
(
fn
,
line
));
mh
->
size
=
~
mh
->
size
;
mh
->
size
=
~
mh
->
size
;
blocks_to_free_ptr
++
;
blocks_to_free_ptr
++
;
blocks_to_free_ptr
%=
FREE_DELAY
;
blocks_to_free_ptr
%=
FREE_DELAY
;
...
@@ -843,6 +848,7 @@ void debug_free(void *p, const char *fn, int line)
...
@@ -843,6 +848,7 @@ void debug_free(void *p, const char *fn, int line)
blocks_to_free
[
blocks_to_free_ptr
]
=
p
;
blocks_to_free
[
blocks_to_free_ptr
]
=
p
;
p
=
p2
;
p
=
p2
;
}
}
}
if
(
remove_memhdr
(
p
,
0
))
p
=
((
char
*
)
p
)
-
DEBUG_MALLOC_PAD
;
if
(
remove_memhdr
(
p
,
0
))
p
=
((
char
*
)
p
)
-
DEBUG_MALLOC_PAD
;
free
(
p
);
free
(
p
);
mt_unlock
(
&
debug_malloc_mutex
);
mt_unlock
(
&
debug_malloc_mutex
);
...
@@ -895,8 +901,10 @@ void cleanup_memhdrs()
...
@@ -895,8 +901,10 @@ void cleanup_memhdrs()
{
{
if
(
remove_memhdr
(
p
,
0
))
p
=
((
char
*
)
p
)
-
DEBUG_MALLOC_PAD
;
if
(
remove_memhdr
(
p
,
0
))
p
=
((
char
*
)
p
)
-
DEBUG_MALLOC_PAD
;
free
(
p
);
free
(
p
);
blocks_to_free
[
h
]
=
0
;
}
}
}
}
exiting
=
1
;
if
(
verbose_debug_exit
)
if
(
verbose_debug_exit
)
{
{
...
...
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