projects
/
platform
/
upstream
/
pulseaudio.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e5c2256
)
core-util: rework pa_strlcpy() to not rely on strncpy()
author
Lennart Poettering
<lennart@poettering.net>
Sat, 1 Aug 2009 00:01:58 +0000
(
02:01
+0200)
committer
Lennart Poettering
<lennart@poettering.net>
Sat, 1 Aug 2009 00:01:58 +0000
(
02:01
+0200)
strncpy() is very slow since it resets the entire destination buffer.
Replace usage of strncpy by memcpy().
src/pulsecore/core-util.c
patch
|
blob
|
history
diff --git
a/src/pulsecore/core-util.c
b/src/pulsecore/core-util.c
index
d01efa2
..
99644d7
100644
(file)
--- a/
src/pulsecore/core-util.c
+++ b/
src/pulsecore/core-util.c
@@
-552,12
+552,20
@@
char *pa_vsprintf_malloc(const char *format, va_list ap) {
/* Similar to OpenBSD's strlcpy() function */
char *pa_strlcpy(char *b, const char *s, size_t l) {
+ size_t k;
+
pa_assert(b);
pa_assert(s);
pa_assert(l > 0);
- strncpy(b, s, l);
- b[l-1] = 0;
+ k = strlen(s);
+
+ if (k > l-1)
+ k = l-1;
+
+ memcpy(b, s, k);
+ b[k] = 0;
+
return b;
}