Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libloc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
libloc
Commits
21dfa79e
Commit
21dfa79e
authored
Aug 22, 2022
by
Michael Tremer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stringpool: Drop function to find next offset
Signed-off-by:
Michael Tremer
<
michael.tremer@ipfire.org
>
parent
c8603967
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
14 deletions
+10
-14
src/stringpool.c
src/stringpool.c
+10
-14
No files found.
src/stringpool.c
View file @
21dfa79e
...
...
@@ -255,14 +255,6 @@ struct loc_stringpool* loc_stringpool_unref(struct loc_stringpool* pool) {
return
NULL
;
}
static
off_t
loc_stringpool_get_next_offset
(
struct
loc_stringpool
*
pool
,
off_t
offset
)
{
const
char
*
string
=
loc_stringpool_get
(
pool
,
offset
);
if
(
!
string
)
return
offset
;
return
offset
+
strlen
(
string
)
+
1
;
}
const
char
*
loc_stringpool_get
(
struct
loc_stringpool
*
pool
,
off_t
offset
)
{
return
__loc_stringpool_get
(
pool
,
offset
);
}
...
...
@@ -280,14 +272,17 @@ static off_t loc_stringpool_find(struct loc_stringpool* pool, const char* s) {
off_t
offset
=
0
;
while
(
offset
<
pool
->
length
)
{
const
char
*
string
=
loc_stringpool_get
(
pool
,
offset
);
// Error!
if
(
!
string
)
break
;
return
1
;
int
r
=
strcmp
(
s
,
string
);
if
(
r
==
0
)
// Is this a match?
if
(
strcmp
(
s
,
string
)
==
0
)
return
offset
;
offset
=
loc_stringpool_get_next_offset
(
pool
,
offset
);
// Shift offset
offset
+=
strlen
(
string
)
+
1
;
}
// Nothing found
...
...
@@ -311,11 +306,12 @@ void loc_stringpool_dump(struct loc_stringpool* pool) {
while
(
offset
<
pool
->
length
)
{
const
char
*
string
=
loc_stringpool_get
(
pool
,
offset
);
if
(
!
string
)
break
;
return
;
printf
(
"%jd (%zu): %s
\n
"
,
(
intmax_t
)
offset
,
strlen
(
string
),
string
);
offset
=
loc_stringpool_get_next_offset
(
pool
,
offset
);
// Shift offset
offset
+=
strlen
(
string
)
+
1
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment