Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
849b0563
Commit
849b0563
authored
Nov 28, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/Alloc: add fallback for gcc 4.6
parent
16a99ad5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
Alloc.cxx
src/util/Alloc.cxx
+21
-0
No files found.
src/util/Alloc.cxx
View file @
849b0563
...
...
@@ -75,6 +75,8 @@ xstrndup(const char *s, size_t n)
return
p
;
}
#if CLANG_OR_GCC_VERSION(4,7)
template
<
typename
...
Args
>
static
inline
size_t
FillLengths
(
size_t
*
lengths
,
const
char
*
a
,
Args
&&
...
args
)
...
...
@@ -104,11 +106,14 @@ StringCat(char *p, const size_t *lengths, const char *a)
memcpy
(
p
,
a
,
*
lengths
);
}
#endif
template
<
typename
...
Args
>
gcc_malloc
gcc_nonnull_all
static
inline
char
*
t_xstrcatdup
(
Args
&&
...
args
)
{
#if CLANG_OR_GCC_VERSION(4,7)
constexpr
size_t
n
=
sizeof
...(
args
);
size_t
lengths
[
n
];
...
...
@@ -118,6 +123,22 @@ t_xstrcatdup(Args&&... args)
StringCat
(
p
,
lengths
,
args
...);
p
[
total
]
=
0
;
return
p
;
#else
/* fallback implementation for gcc 4.6, because that old
compiler is too buggy to compile the above template
functions */
const
char
*
const
argv
[]
=
{
args
...
};
size_t
total
=
0
;
for
(
auto
i
:
argv
)
total
+=
strlen
(
i
);
char
*
p
=
(
char
*
)
xalloc
(
total
+
1
),
*
q
=
p
;
for
(
auto
i
:
argv
)
q
=
stpcpy
(
q
,
i
);
return
p
;
#endif
}
char
*
...
...
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