Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
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
Container registry
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
c0fc6a1f
Commit
c0fc6a1f
authored
10 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
Add gpr_ltoa
parent
55f17830
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/grpc/support/string.h
+7
-0
7 additions, 0 deletions
include/grpc/support/string.h
src/core/support/string.c
+30
-0
30 additions, 0 deletions
src/core/support/string.c
with
37 additions
and
0 deletions
include/grpc/support/string.h
+
7
−
0
View file @
c0fc6a1f
...
...
@@ -60,6 +60,13 @@ char *gpr_hexdump(const char *buf, size_t len, gpr_uint32 flags);
int
gpr_parse_bytes_to_uint32
(
const
char
*
data
,
size_t
length
,
gpr_uint32
*
result
);
/* Convert a long to a string in base 10; returns the length of the
output string (or 0 on failure) */
int
gpr_ltoa
(
long
value
,
char
*
output
);
/* Reverse a run of bytes */
void
gpr_reverse_bytes
(
char
*
str
,
int
len
);
/* printf to a newly-allocated string. The set of supported formats may vary
between platforms.
...
...
This diff is collapsed.
Click to expand it.
src/core/support/string.c
+
30
−
0
View file @
c0fc6a1f
...
...
@@ -122,3 +122,33 @@ int gpr_parse_bytes_to_uint32(const char *buf, size_t len, gpr_uint32 *result) {
*
result
=
out
;
return
1
;
}
void
gpr_reverse_bytes
(
char
*
str
,
int
len
)
{
char
*
p1
,
*
p2
;
for
(
p1
=
str
,
p2
=
str
+
len
-
1
;
p2
>
p1
;
++
p1
,
--
p2
)
{
char
temp
=
*
p1
;
*
p1
=
*
p2
;
*
p2
=
temp
;
}
}
int
gpr_ltoa
(
long
value
,
char
*
string
)
{
int
i
=
0
;
int
neg
=
value
<
0
;
if
(
value
==
0
)
{
string
[
0
]
=
'0'
;
string
[
1
]
=
0
;
return
1
;
}
if
(
neg
)
value
=
-
value
;
while
(
value
)
{
string
[
i
++
]
=
'0'
+
value
%
10
;
value
/=
10
;
}
if
(
neg
)
string
[
i
++
]
=
'-'
;
gpr_reverse_bytes
(
string
,
i
);
string
[
i
]
=
0
;
return
i
;
}
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