Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
James Lowden
OpenLDAP
Commits
368f2814
Commit
368f2814
authored
15 years ago
by
Hallvard Furuseth
Committed by
Quanah Gibson-Mount
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ITS#6437: Fix pool version misalignment: It aligned heads, not returned blocks
parent
e100826c
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
servers/slapd/sl_malloc.c
+18
-12
18 additions, 12 deletions
servers/slapd/sl_malloc.c
with
18 additions
and
12 deletions
servers/slapd/sl_malloc.c
+
18
−
12
View file @
368f2814
...
...
@@ -180,35 +180,40 @@ slap_sl_mem_create(
struct
slab_heap
*
sh
;
ber_len_t
size_shift
;
struct
slab_object
*
so
;
char
*
base
,
*
newptr
;
enum
{
Base_offset
=
(
unsigned
)
-
sizeof
(
ber_len_t
)
%
Align
};
sh
=
GET_MEMCTX
(
thrctx
,
&
memctx
);
if
(
sh
&&
!
new
)
return
sh
;
/* round up to doubleword boundary */
size
=
(
size
+
Align
-
1
)
&
-
Align
;
/* Round up to doubleword boundary, then make room for initial
* padding, preserving expected available size for pool version */
size
=
((
size
+
Align
-
1
)
&
-
Align
)
+
Base_offset
;
if
(
!
sh
)
{
sh
=
ch_malloc
(
sizeof
(
struct
slab_heap
));
sh
->
sh_
base
=
ch_malloc
(
size
);
base
=
ch_malloc
(
size
);
SET_MEMCTX
(
thrctx
,
sh
,
slap_sl_mem_destroy
);
}
else
{
slap_sl_mem_destroy
(
NULL
,
sh
);
if
(
size
>
(
char
*
)
sh
->
sh_end
-
(
char
*
)
sh
->
sh_base
)
{
void
*
newptr
;
newptr
=
ch_realloc
(
sh
->
sh_base
,
size
);
base
=
sh
->
sh_base
;
if
(
size
>
(
ber_len_t
)
((
char
*
)
sh
->
sh_end
-
base
))
{
newptr
=
ch_realloc
(
base
,
size
);
if
(
newptr
==
NULL
)
return
NULL
;
sh
->
sh_
base
=
newptr
;
base
=
newptr
;
}
}
sh
->
sh_end
=
(
char
*
)
sh
->
sh_base
+
size
;
sh
->
sh_base
=
base
;
sh
->
sh_end
=
base
+
size
;
/* Align (base + head of first block) == first returned block */
base
+=
Base_offset
;
size
-=
Base_offset
;
sh
->
sh_stack
=
stack
;
if
(
stack
)
{
/* Align first returned block (sh_last + head) */
sh
->
sh_last
=
(
char
*
)
sh
->
sh_base
+
Base_offset
;
sh
->
sh_last
=
base
;
}
else
{
int
i
,
order
=
-
1
,
order_end
=
-
1
;
...
...
@@ -233,7 +238,7 @@ slap_sl_mem_create(
}
so
=
LDAP_LIST_FIRST
(
&
sh
->
sh_sopool
);
LDAP_LIST_REMOVE
(
so
,
so_link
);
so
->
so_ptr
=
sh
->
sh_
base
;
so
->
so_ptr
=
base
;
LDAP_LIST_INSERT_HEAD
(
&
sh
->
sh_free
[
order
-
1
],
so
,
so_link
);
...
...
@@ -249,6 +254,7 @@ slap_sl_mem_create(
memset
(
sh
->
sh_map
[
i
],
0
,
nummaps
);
}
}
return
sh
;
}
...
...
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