Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sparse
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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
raphael.bach
sparse
Commits
53329b73
There was a problem fetching the pipeline summary.
Commit
53329b73
authored
6 years ago
by
raphael.bach
Browse files
Options
Downloads
Patches
Plain Diff
Add Sparse_GuessBlockSize()
parent
99f6df76
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/sparse.h
+4
-0
4 additions, 0 deletions
include/sparse.h
src/sparse.c
+18
-0
18 additions, 0 deletions
src/sparse.c
with
22 additions
and
0 deletions
include/sparse.h
+
4
−
0
View file @
53329b73
...
...
@@ -157,6 +157,10 @@ void Sparse_PrintChunkHeader(const struct Sparse_Chunk * const header);
Sparse_DumpInfo()
------------------------------------------------------------------------------*/
void
Sparse_DumpInfo
(
const
struct
Sparse
*
const
sparse
);
/*------------------------------------------------------------------------------
Sparse_GuessBlockSize()
------------------------------------------------------------------------------*/
size_t
Sparse_GuessBlockSize
(
size_t
img_size
);
/*==============================================================================
GUARD
==============================================================================*/
...
...
This diff is collapsed.
Click to expand it.
src/sparse.c
+
18
−
0
View file @
53329b73
...
...
@@ -58,6 +58,9 @@ static struct Logger s_logger = {
.
level_flag
=
LOG_LEVEL_ALL
,
.
output
=
LOG_OUTPUT_STDERR
};
static
const
size_t
s_block_size_list
[]
=
{
4096
,
2048
,
1024
};
/*==============================================================================
PUBLIC FUNCTION DEFINITION
==============================================================================*/
...
...
@@ -333,3 +336,18 @@ void Sparse_DumpInfo(const struct Sparse * const sparse)
printf
(
"%zu
\n
"
,
(
sparse
->
chunks
+
i
)
->
size
+
CHUNK_HEADER_SIZE
);
}
}
/*------------------------------------------------------------------------------
Sparse_GuessBlockSize()
------------------------------------------------------------------------------*/
size_t
Sparse_GuessBlockSize
(
size_t
img_size
)
{
size_t
block_size
=
0
;
size_t
array_size
=
sizeof
(
s_block_size_list
)
/
sizeof
(
size_t
);
for
(
size_t
i
=
0
;
i
<
array_size
;
i
++
)
{
if
((
img_size
%
s_block_size_list
[
i
])
==
0
)
{
block_size
=
s_block_size_list
[
i
];
break
;
}
}
return
block_size
;
}
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