pointer, size);
}
-/* Like pstrdup(), but append null byte */
-char *
-pnstrdup(const char *in, int len)
-{
- char *out = palloc(len + 1);
-
- memcpy(out, in, len);
- out[len] = '\0';
- return out;
-}
-
-
/*
* MemoryContextSwitchTo
* Returns the current context; installs the given context.
return nstr;
}
+/*
+ * pnstrdup
+ * Like pstrdup(), but append null byte to a
+ * not-necessarily-null-terminated input string.
+ */
+char *
+pnstrdup(const char *in, Size len)
+{
+ char *out = palloc(len + 1);
+
+ memcpy(out, in, len);
+ out[len] = '\0';
+ return out;
+}
+
#if defined(WIN32) || defined(__CYGWIN__)
/*
extern void *repalloc(void *pointer, Size size);
-extern char *pnstrdup(const char *in, int len);
-
/*
* MemoryContextSwitchTo can't be a macro in standard C compilers.
* But we can make it an inline function when using GCC.
#define pstrdup(str) MemoryContextStrdup(CurrentMemoryContext, (str))
+extern char *pnstrdup(const char *in, Size len);
+
#if defined(WIN32) || defined(__CYGWIN__)
extern void *pgport_palloc(Size sz);
extern char *pgport_pstrdup(const char *str);