1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-01 12:18:01 +03:00

If pnstrdup is going to be promoted to a generally available function,

it ought to conform to the rest of palloc.h in using Size for sizes.
This commit is contained in:
Tom Lane
2008-06-28 16:45:22 +00:00
parent dcc2334736
commit 4a8d573cda
2 changed files with 19 additions and 16 deletions

View File

@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.64 2008/06/18 18:42:54 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.65 2008/06/28 16:45:22 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -624,18 +624,6 @@ repalloc(void *pointer, Size size)
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.
@@ -676,6 +664,21 @@ MemoryContextStrdup(MemoryContext context, const char *string)
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__)
/*