summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Lidén Borell <samuel@kodafritt.se>2014-10-27 07:49:36 (GMT)
committerSamuel Lidén Borell <samuel@kodafritt.se>2014-10-27 07:49:36 (GMT)
commitc65759c6bc554b95c282ab98b28112df8628b43a (patch)
treed21ae7b5b7b803431d436d79bd625c2334af1b0a
parent61c557b5daeb093a4365793e845f171692183307 (diff)
downloadfribid-c65759c6bc554b95c282ab98b28112df8628b43a.zip
fribid-c65759c6bc554b95c282ab98b28112df8628b43a.tar.gz
fribid-c65759c6bc554b95c282ab98b28112df8628b43a.tar.bz2
Rename strndup to f_strndup
With strndup it failed to compile under Arch Linux. Also, names starting with str* are reserved in C89 / ANSI C (section 4.13.7) and C99 (section 7.26.10).
-rw-r--r--plugin/pluginutil.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/plugin/pluginutil.c b/plugin/pluginutil.c
index c29d9a2..fd81386 100644
--- a/plugin/pluginutil.c
+++ b/plugin/pluginutil.c
@@ -14,7 +14,10 @@
#include "pluginutil.h"
-static char *strndup(const char *source, size_t maxLength) {
+/**
+ * Implementation of strndup in case the system doesn't have that.
+ */
+static char *f_strndup(const char *source, size_t maxLength) {
size_t i;
for (i = 0;; i++) {
if ((i >= maxLength) || (source[i] == '\0')) break;
@@ -31,7 +34,7 @@ static char *strndup(const char *source, size_t maxLength) {
* Creates a new null terminated string from an NPVariant string.
*/
char *variantToStringZ(const NPVariant *variant) {
- return strndup(NPVARIANT_TO_STRING(*variant).utf8characters, NPVARIANT_TO_STRING(*variant).utf8length);
+ return f_strndup(NPVARIANT_TO_STRING(*variant).utf8characters, NPVARIANT_TO_STRING(*variant).utf8length);
}
// Re-allocates a string with NPN_MemAlloc instead of malloc
@@ -105,8 +108,8 @@ static char *getWindowProperty(NPP instance, const char *identifiers) {
NPN_ReleaseVariantValue(&value);
return NULL;
}
- char *url = strndup(NPVARIANT_TO_STRING(value).utf8characters,
- NPVARIANT_TO_STRING(value).utf8length);
+ char *url = f_strndup(NPVARIANT_TO_STRING(value).utf8characters,
+ NPVARIANT_TO_STRING(value).utf8length);
NPN_ReleaseVariantValue(&value);
return url;
}