Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
apk-tools
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
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
socksinspace
apk-tools
Commits
8bd34603
Commit
8bd34603
authored
7 months ago
by
Timo Teräs
Browse files
Options
Downloads
Patches
Plain Diff
atom: use bump allocator
parent
aef59817
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/apk_atom.h
+2
-0
2 additions, 0 deletions
src/apk_atom.h
src/atom.c
+4
-3
4 additions, 3 deletions
src/atom.c
with
6 additions
and
3 deletions
src/apk_atom.h
+
2
−
0
View file @
8bd34603
...
...
@@ -12,10 +12,12 @@
#include
"apk_hash.h"
#include
"apk_blob.h"
#include
"apk_balloc.h"
extern
apk_blob_t
apk_atom_null
;
struct
apk_atom_pool
{
struct
apk_balloc
ba
;
struct
apk_hash
hash
;
};
...
...
This diff is collapsed.
Click to expand it.
src/atom.c
+
4
−
3
View file @
8bd34603
...
...
@@ -26,17 +26,18 @@ static struct apk_hash_ops atom_ops = {
.
get_key
=
atom_hash_get_key
,
.
hash_key
=
apk_blob_hash
,
.
compare
=
apk_blob_compare
,
.
delete_item
=
(
apk_hash_delete_f
)
free
,
};
void
apk_atom_init
(
struct
apk_atom_pool
*
atoms
)
{
apk_balloc_init
(
&
atoms
->
ba
,
64
*
1024
);
apk_hash_init
(
&
atoms
->
hash
,
&
atom_ops
,
10000
);
}
void
apk_atom_free
(
struct
apk_atom_pool
*
atoms
)
{
apk_hash_free
(
&
atoms
->
hash
);
apk_balloc_destroy
(
&
atoms
->
ba
);
}
apk_blob_t
*
apk_atom_get
(
struct
apk_atom_pool
*
atoms
,
apk_blob_t
blob
,
int
duplicate
)
...
...
@@ -51,12 +52,12 @@ apk_blob_t *apk_atom_get(struct apk_atom_pool *atoms, apk_blob_t blob, int dupli
if
(
duplicate
)
{
char
*
ptr
;
atom
=
malloc
(
sizeof
(
*
atom
)
+
blob
.
len
);
atom
=
apk_balloc_new_extra
(
&
atoms
->
ba
,
struct
apk_atom_hashnode
,
blob
.
len
);
ptr
=
(
char
*
)
(
atom
+
1
);
memcpy
(
ptr
,
blob
.
ptr
,
blob
.
len
);
atom
->
blob
=
APK_BLOB_PTR_LEN
(
ptr
,
blob
.
len
);
}
else
{
atom
=
malloc
(
sizeof
(
*
atom
)
);
atom
=
apk_balloc_new
(
&
atoms
->
ba
,
struct
apk_atom_hashnode
);
atom
->
blob
=
blob
;
}
apk_hash_insert_hashed
(
&
atoms
->
hash
,
atom
,
hash
);
...
...
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