Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EtherBone Core
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Projects
EtherBone Core
Commits
d6b56ff6
Commit
d6b56ff6
authored
13 years ago
by
Wesley W. Terpstra
Browse files
Options
Downloads
Patches
Plain Diff
We can't allocate more than 64k worth of entries, because 64k-1 is EB_NULL.
parent
2f48036d
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/memory/dynamic.c
+6
-3
6 additions, 3 deletions
api/memory/dynamic.c
with
6 additions
and
3 deletions
api/memory/dynamic.c
+
6
−
3
View file @
d6b56ff6
...
...
@@ -36,11 +36,14 @@
#include
"memory.h"
union
eb_memory_item
*
eb_memory_array
=
0
;
static
EB_POINTER
(
eb_memory_item
)
eb_memory_array_size
=
128
;
/* ie: initally 256 */
static
uint32_t
eb_memory_array_size
=
128
;
/* ie: initally 256 */
int
eb_expand_array
(
void
)
{
void
*
new_address
;
EB_POINTER
(
eb_memory_item
)
next_size
,
i
;
uint32_t
next_size
,
i
;
/* When next_size reaches the maximum of 64k entries, fail */
if
(
eb_memory_array_size
==
65536
)
return
-
1
;
/* Doubling ensures constant cost */
next_size
=
eb_memory_array_size
+
eb_memory_array_size
;
...
...
@@ -58,7 +61,7 @@ int eb_expand_array(void) {
/* Link together the expanded free list */
for
(
i
=
eb_memory_array_size
;
i
!=
next_size
;
++
i
)
eb_memory_array
[
i
].
free_item
.
next
=
i
+
1
;
eb_memory_array
[
next_size
-
1
].
free_item
.
next
=
EB_END_OF_FREE
;
eb_memory_free
=
eb_memory_array_size
;
eb_memory_array_size
=
next_size
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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