Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hammer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Automate
Agent sessions
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vyrus
hammer
Commits
ec824951
Commit
ec824951
authored
Dec 7, 2016
by
Sven M. Hallberg
Browse files
Options
Downloads
Patches
Plain Diff
avoid more void pointer arithmetic
parent
fedb36ed
Loading
Loading
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sloballoc.c
+3
-3
3 additions, 3 deletions
src/sloballoc.c
with
3 additions
and
3 deletions
src/sloballoc.c
+
3
−
3
View file @
ec824951
...
@@ -30,7 +30,7 @@ SLOB *slobinit(void *mem, size_t size)
...
@@ -30,7 +30,7 @@ SLOB *slobinit(void *mem, size_t size)
slob
=
mem
;
slob
=
mem
;
slob
->
size
=
size
-
sizeof
(
SLOB
);
slob
->
size
=
size
-
sizeof
(
SLOB
);
slob
->
head
=
mem
+
sizeof
(
SLOB
);
slob
->
head
=
(
struct
block
*
)((
uint8_t
*
)
mem
+
sizeof
(
SLOB
)
)
;
slob
->
head
->
alloc
.
size
=
slob
->
size
-
sizeof
(
struct
alloc
);
slob
->
head
->
alloc
.
size
=
slob
->
size
-
sizeof
(
struct
alloc
);
slob
->
head
->
next
=
NULL
;
slob
->
head
->
next
=
NULL
;
...
@@ -70,7 +70,7 @@ void *sloballoc(SLOB *slob, size_t size)
...
@@ -70,7 +70,7 @@ void *sloballoc(SLOB *slob, size_t size)
void
slobfree
(
SLOB
*
slob
,
void
*
a_
)
void
slobfree
(
SLOB
*
slob
,
void
*
a_
)
{
{
struct
alloc
*
a
=
a_
-
sizeof
(
struct
alloc
);
struct
alloc
*
a
=
(
struct
alloc
*
)((
uint8_t
*
)
a_
-
sizeof
(
struct
alloc
)
)
;
struct
block
*
b
,
**
p
,
*
left
=
NULL
,
*
right
=
NULL
,
**
rightp
=
NULL
;
struct
block
*
b
,
**
p
,
*
left
=
NULL
,
*
right
=
NULL
,
**
rightp
=
NULL
;
// sanity check: a lies inside slob
// sanity check: a lies inside slob
...
@@ -203,7 +203,7 @@ HAllocator *h_sloballoc(void *mem, size_t size)
...
@@ -203,7 +203,7 @@ HAllocator *h_sloballoc(void *mem, size_t size)
return
NULL
;
return
NULL
;
HAllocator
*
mm
=
mem
;
HAllocator
*
mm
=
mem
;
SLOB
*
slob
=
slobinit
(
mem
+
sizeof
(
HAllocator
),
size
-
sizeof
(
HAllocator
));
SLOB
*
slob
=
slobinit
(
(
uint8_t
*
)
mem
+
sizeof
(
HAllocator
),
size
-
sizeof
(
HAllocator
));
if
(
!
slob
)
if
(
!
slob
)
return
NULL
;
return
NULL
;
assert
(
slob
==
(
SLOB
*
)(
mm
+
1
));
assert
(
slob
==
(
SLOB
*
)(
mm
+
1
));
...
...
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
sign in
to comment