Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4a8d573

Browse files
committed
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.
1 parentdcc2334 commit4a8d573

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

‎src/backend/utils/mmgr/mcxt.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
*
1616
* IDENTIFICATION
17-
* $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.64 2008/06/18 18:42:54 momjian Exp $
17+
* $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.65 2008/06/28 16:45:22 tgl Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
@@ -624,18 +624,6 @@ repalloc(void *pointer, Size size)
624624
pointer,size);
625625
}
626626

627-
/* Like pstrdup(), but append null byte */
628-
char*
629-
pnstrdup(constchar*in,intlen)
630-
{
631-
char*out=palloc(len+1);
632-
633-
memcpy(out,in,len);
634-
out[len]='\0';
635-
returnout;
636-
}
637-
638-
639627
/*
640628
* MemoryContextSwitchTo
641629
*Returns the current context; installs the given context.
@@ -676,6 +664,21 @@ MemoryContextStrdup(MemoryContext context, const char *string)
676664
returnnstr;
677665
}
678666

667+
/*
668+
* pnstrdup
669+
*Like pstrdup(), but append null byte to a
670+
*not-necessarily-null-terminated input string.
671+
*/
672+
char*
673+
pnstrdup(constchar*in,Sizelen)
674+
{
675+
char*out=palloc(len+1);
676+
677+
memcpy(out,in,len);
678+
out[len]='\0';
679+
returnout;
680+
}
681+
679682

680683
#if defined(WIN32)|| defined(__CYGWIN__)
681684
/*

‎src/include/utils/palloc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
2222
* Portions Copyright (c) 1994, Regents of the University of California
2323
*
24-
* $PostgreSQL: pgsql/src/include/utils/palloc.h,v 1.39 2008/06/18 18:42:54 momjian Exp $
24+
* $PostgreSQL: pgsql/src/include/utils/palloc.h,v 1.40 2008/06/28 16:45:22 tgl Exp $
2525
*
2626
*-------------------------------------------------------------------------
2727
*/
@@ -70,8 +70,6 @@ extern void pfree(void *pointer);
7070

7171
externvoid*repalloc(void*pointer,Sizesize);
7272

73-
externchar*pnstrdup(constchar*in,intlen);
74-
7573
/*
7674
* MemoryContextSwitchTo can't be a macro in standard C compilers.
7775
* But we can make it an inline function when using GCC.
@@ -99,6 +97,8 @@ extern char *MemoryContextStrdup(MemoryContext context, const char *string);
9997

10098
#definepstrdup(str) MemoryContextStrdup(CurrentMemoryContext, (str))
10199

100+
externchar*pnstrdup(constchar*in,Sizelen);
101+
102102
#if defined(WIN32)|| defined(__CYGWIN__)
103103
externvoid*pgport_palloc(Sizesz);
104104
externchar*pgport_pstrdup(constchar*str);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp