Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
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
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
Main
Synchronet
Commits
f9843118
Commit
f9843118
authored
7 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Add a precision argument to byte_estimate_to_str() so the caller can control
the number of decimal places in the resulting string.
parent
6ce7276c
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/xpdev/genwrap.c
+5
-5
5 additions, 5 deletions
src/xpdev/genwrap.c
src/xpdev/genwrap.h
+1
-1
1 addition, 1 deletion
src/xpdev/genwrap.h
with
6 additions
and
6 deletions
src/xpdev/genwrap.c
+
5
−
5
View file @
f9843118
...
@@ -311,16 +311,16 @@ char* DLLCALL byte_count_to_str(int64_t bytes, char* str, size_t size)
...
@@ -311,16 +311,16 @@ char* DLLCALL byte_count_to_str(int64_t bytes, char* str, size_t size)
This function also appends 'B' for exact byte counts (< 1024).
This function also appends 'B' for exact byte counts (< 1024).
'unit' is the smallest divisor used.
'unit' is the smallest divisor used.
*/
*/
char
*
DLLCALL
byte_estimate_to_str
(
int64_t
bytes
,
char
*
str
,
size_t
size
,
ulong
unit
)
char
*
DLLCALL
byte_estimate_to_str
(
int64_t
bytes
,
char
*
str
,
size_t
size
,
ulong
unit
,
int
precision
)
{
{
if
(
bytes
>=
one_tebibyte
)
if
(
bytes
>=
one_tebibyte
)
safe_snprintf
(
str
,
size
,
"%1.
1
fT"
,
bytes
/
one_tebibyte
);
safe_snprintf
(
str
,
size
,
"%1.
*
fT"
,
precision
,
bytes
/
one_tebibyte
);
else
if
(
bytes
>=
one_gibibyte
||
unit
==
one_gibibyte
)
else
if
(
bytes
>=
one_gibibyte
||
unit
==
one_gibibyte
)
safe_snprintf
(
str
,
size
,
"%1.
1
fG"
,
bytes
/
one_gibibyte
);
safe_snprintf
(
str
,
size
,
"%1.
*
fG"
,
precision
,
bytes
/
one_gibibyte
);
else
if
(
bytes
>=
one_mebibyte
||
unit
==
one_mebibyte
)
else
if
(
bytes
>=
one_mebibyte
||
unit
==
one_mebibyte
)
safe_snprintf
(
str
,
size
,
"%1.
1
fM"
,
bytes
/
one_mebibyte
);
safe_snprintf
(
str
,
size
,
"%1.
*
fM"
,
precision
,
bytes
/
one_mebibyte
);
else
if
(
bytes
>=
one_kibibyte
||
unit
==
one_kibibyte
)
else
if
(
bytes
>=
one_kibibyte
||
unit
==
one_kibibyte
)
safe_snprintf
(
str
,
size
,
"%1.
1
fK"
,
bytes
/
one_kibibyte
);
safe_snprintf
(
str
,
size
,
"%1.
*
fK"
,
precision
,
bytes
/
one_kibibyte
);
else
else
safe_snprintf
(
str
,
size
,
"%"
PRIi64
"B"
,
bytes
);
safe_snprintf
(
str
,
size
,
"%"
PRIi64
"B"
,
bytes
);
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/genwrap.h
+
1
−
1
View file @
f9843118
...
@@ -374,7 +374,7 @@ DLLEXPORT double DLLCALL parse_duration(const char*);
...
@@ -374,7 +374,7 @@ DLLEXPORT double DLLCALL parse_duration(const char*);
DLLEXPORT
char
*
DLLCALL
duration_to_str
(
double
value
,
char
*
str
,
size_t
size
);
DLLEXPORT
char
*
DLLCALL
duration_to_str
(
double
value
,
char
*
str
,
size_t
size
);
DLLEXPORT
char
*
DLLCALL
duration_to_vstr
(
double
value
,
char
*
str
,
size_t
size
);
DLLEXPORT
char
*
DLLCALL
duration_to_vstr
(
double
value
,
char
*
str
,
size_t
size
);
DLLEXPORT
char
*
DLLCALL
byte_count_to_str
(
int64_t
bytes
,
char
*
str
,
size_t
size
);
DLLEXPORT
char
*
DLLCALL
byte_count_to_str
(
int64_t
bytes
,
char
*
str
,
size_t
size
);
DLLEXPORT
char
*
DLLCALL
byte_estimate_to_str
(
int64_t
bytes
,
char
*
str
,
size_t
size
,
ulong
unit
);
DLLEXPORT
char
*
DLLCALL
byte_estimate_to_str
(
int64_t
bytes
,
char
*
str
,
size_t
size
,
ulong
unit
,
int
precision
);
/* Microsoft (e.g. DOS/Win32) real-time system clock API (ticks since process started) */
/* Microsoft (e.g. DOS/Win32) real-time system clock API (ticks since process started) */
typedef
clock_t
msclock_t
;
typedef
clock_t
msclock_t
;
...
...
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