Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Miosix Kernel
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
Avionics
Software Development
Miosix Kernel
Commits
277ac7c7
Commit
277ac7c7
authored
13 years ago
by
Terraneo Federico
Browse files
Options
Downloads
Patches
Plain Diff
Starting the implementation of the pool allocator
parent
0846e98f
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+1
-1
1 addition, 1 deletion
Makefile
pool_allocator.cpp
+26
-0
26 additions, 0 deletions
pool_allocator.cpp
pool_allocator.h
+30
-0
30 additions, 0 deletions
pool_allocator.h
with
57 additions
and
1 deletion
Makefile
+
1
−
1
View file @
277ac7c7
...
@@ -14,7 +14,7 @@ SUBDIRS := miosix
...
@@ -14,7 +14,7 @@ SUBDIRS := miosix
## List here your source files (both .s, .c and .cpp)
## List here your source files (both .s, .c and .cpp)
##
##
SRC
:=
\
SRC
:=
\
main.cpp
main.cpp
pool_allocator.cpp
##
##
## List here additional static libraries with relative path
## List here additional static libraries with relative path
...
...
This diff is collapsed.
Click to expand it.
pool_allocator.cpp
0 → 100644
+
26
−
0
View file @
277ac7c7
#include
"pool_allocator.h"
PoolAllocator
::
PoolAllocator
(
unsigned
int
*
poolBase
,
unsigned
int
poolSize
)
:
poolBase
(
poolBase
),
poolSize
(
poolSize
)
{
bitmap
=
new
unsigned
int
[
poolSize
/
blockSize
/
sizeof
(
unsigned
int
)];
}
unsigned
int
*
PoolAllocator
::
allocate
(
int
size
)
{
//TODO : align this, and validate size to prevent wraparound
unsigned
int
offset
=
0
;
if
(
poolBase
%
size
)
offset
=
size
-
(
poolBase
%
size
);
int
startBit
=
offset
/
blockSize
;
}
void
PoolAllocator
::
deallocate
(
unsigned
int
*
ptr
)
{
}
PoolAllocator
::~
PoolAllocator
()
{
delete
[]
bitmap
;
}
This diff is collapsed.
Click to expand it.
pool_allocator.h
0 → 100644
+
30
−
0
View file @
277ac7c7
#include
<map>
#ifndef POOL_ALLOCATOR
#define POOL_ALLOCATOR
class
PoolAllocator
{
public:
PoolAllocator
(
unsigned
int
*
poolBase
,
unsigned
int
poolSize
);
unsigned
int
*
allocate
(
int
size
);
void
deallocate
(
unsigned
int
*
ptr
);
~
PoolAllocator
();
static
const
int
blockSize
=
1024
;
private:
PoolAllocator
(
const
PoolAllocator
&
);
PoolAllocator
&
operator
=
(
const
PoolAllocator
&
);
unsigned
int
*
bitmap
;
unsigned
int
*
poolBase
;
unsigned
int
poolSize
;
std
::
map
<
unsigned
int
*
,
unsigned
int
>
allocatedBlocks
;
};
#endif //POOL_ALLOCATOR
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