projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
.gitignore: ignore local vscode workspace settings file
[lttng-tools.git]
/
src
/
common
/
string-utils
/
string-utils.cpp
diff --git
a/src/common/string-utils/string-utils.cpp
b/src/common/string-utils/string-utils.cpp
index 3fecd87a1b00e6c02c72c6e87001b8a500f9d9bf..4f727e2e8ed0fe9f407249e538a4dfe1b80d7f85 100644
(file)
--- a/
src/common/string-utils/string-utils.cpp
+++ b/
src/common/string-utils/string-utils.cpp
@@
-375,7
+375,7
@@
int strutils_append_str(char **s, const char *append)
{
char *old = *s;
char *new_str;
{
char *old = *s;
char *new_str;
- size_t oldlen = (old ==
NULL
) ? 0 : strlen(old);
+ size_t oldlen = (old ==
nullptr
) ? 0 : strlen(old);
size_t appendlen = strlen(append);
new_str = zmalloc<char>(oldlen + appendlen + 1);
size_t appendlen = strlen(append);
new_str = zmalloc<char>(oldlen + appendlen + 1);
@@
-395,12
+395,13
@@
int strutils_appendf(char **s, const char *fmt, ...)
{
char *new_str;
size_t oldlen = (*s) ? strlen(*s) : 0;
{
char *new_str;
size_t oldlen = (*s) ? strlen(*s) : 0;
+ size_t addlen = 0;
int ret;
va_list args;
/* Compute length of formatted string we append. */
va_start(args, fmt);
int ret;
va_list args;
/* Compute length of formatted string we append. */
va_start(args, fmt);
- ret = vsnprintf(
NULL
, 0, fmt, args);
+ ret = vsnprintf(
nullptr
, 0, fmt, args);
va_end(args);
if (ret == -1) {
va_end(args);
if (ret == -1) {
@@
-408,7
+409,8
@@
int strutils_appendf(char **s, const char *fmt, ...)
}
/* Allocate space for old string + new string + \0. */
}
/* Allocate space for old string + new string + \0. */
- new_str = zmalloc<char>(oldlen + ret + 1);
+ addlen = ret + 1;
+ new_str = zmalloc<char>(oldlen + addlen);
if (!new_str) {
ret = -ENOMEM;
goto end;
if (!new_str) {
ret = -ENOMEM;
goto end;
@@
-421,7
+423,7
@@
int strutils_appendf(char **s, const char *fmt, ...)
/* Format new string in-place. */
va_start(args, fmt);
/* Format new string in-place. */
va_start(args, fmt);
- ret = vs
printf(&new_str[oldlen]
, fmt, args);
+ ret = vs
nprintf(&new_str[oldlen], addlen
, fmt, args);
va_end(args);
if (ret == -1) {
va_end(args);
if (ret == -1) {
@@
-431,7
+433,7
@@
int strutils_appendf(char **s, const char *fmt, ...)
free(*s);
*s = new_str;
free(*s);
*s = new_str;
- new_str =
NULL
;
+ new_str =
nullptr
;
end:
return ret;
end:
return ret;
This page took
0.024799 seconds
and
4
git commands to generate.