Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
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
Christopher Ng
OpenLDAP
Commits
09fe2bc9
Commit
09fe2bc9
authored
25 years ago
by
Kurt Zeilenga
Browse files
Options
Downloads
Patches
Plain Diff
Add experimental wrong heap detection behind LDAP_MEMORY_DEBUG macro.
parent
c10742a7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libraries/liblber/memory.c
+53
-1
53 additions, 1 deletion
libraries/liblber/memory.c
with
53 additions
and
1 deletion
libraries/liblber/memory.c
+
53
−
1
View file @
09fe2bc9
...
...
@@ -9,8 +9,20 @@
#include
"lber-int.h"
BerMemoryFunctions
*
ber_int_memory_fns
=
NULL
;
#ifdef LDAP_MEMORY_DEBUG
struct
ber_mem_hdr
{
union
bmu_align_u
{
size_t
bmu_size_t
;
void
*
bmu_voidp
;
double
bmu_double
;
long
bmu_long
;
}
ber_align
;
#define bm_junk ber_align.bmu_size_t
};
#define BER_MEM_JUNK 0xddeeddeeU
#endif
BerMemoryFunctions
*
ber_int_memory_fns
=
NULL
;
void
ber_memfree
(
void
*
p
)
...
...
@@ -26,12 +38,20 @@ ber_memfree( void *p )
}
if
(
ber_int_memory_fns
==
NULL
)
{
#ifdef LDAP_MEMORY_DEBUG
struct
ber_mem_hdr
*
mh
=
(
struct
ber_mem_hdr
*
)
((
char
*
)
p
-
sizeof
(
struct
ber_mem_hdr
));
assert
(
mh
->
bm_junk
==
BER_MEM_JUNK
);
free
(
mh
);
#else
free
(
p
);
#endif
return
;
}
assert
(
ber_int_memory_fns
->
bmf_free
);
(
*
ber_int_memory_fns
->
bmf_free
)(
p
);
}
...
...
@@ -65,7 +85,17 @@ ber_memalloc( size_t s )
}
if
(
ber_int_memory_fns
==
NULL
)
{
#ifdef LDAP_MEMORY_DEBUG
struct
ber_mem_hdr
*
mh
=
malloc
(
s
+
sizeof
(
struct
ber_mem_hdr
));
if
(
mh
==
NULL
)
return
NULL
;
mh
->
bm_junk
=
BER_MEM_JUNK
;
return
&
mh
[
1
];
#else
return
malloc
(
s
);
#endif
}
assert
(
ber_int_memory_fns
->
bmf_malloc
);
...
...
@@ -88,7 +118,15 @@ ber_memcalloc( size_t n, size_t s )
}
if
(
ber_int_memory_fns
==
NULL
)
{
#ifdef LDAP_MEMORY_DEBUG
struct
ber_mem_hdr
*
mh
=
calloc
(
1
,
(
n
*
s
)
+
sizeof
(
struct
ber_mem_hdr
)
);
mh
->
bm_junk
=
BER_MEM_JUNK
;
return
&
mh
[
1
];
#else
return
calloc
(
n
,
s
);
#endif
}
assert
(
ber_int_memory_fns
->
bmf_calloc
);
...
...
@@ -114,7 +152,21 @@ ber_memrealloc( void* p, size_t s )
}
if
(
ber_int_memory_fns
==
NULL
)
{
#ifdef LDAP_MEMORY_DEBUG
struct
ber_mem_hdr
*
mh
=
(
struct
ber_mem_hdr
*
)
((
char
*
)
p
-
sizeof
(
struct
ber_mem_hdr
));
assert
(
mh
->
bm_junk
==
BER_MEM_JUNK
);
p
=
realloc
(
mh
,
s
);
if
(
p
==
NULL
)
return
NULL
;
mh
=
p
;
return
&
mh
[
1
];
#else
return
realloc
(
p
,
s
);
#endif
}
assert
(
ber_int_memory_fns
->
bmf_realloc
);
...
...
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