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

Commit97fe5b8

Browse files
committed
fix for windows: conditional strndup() replacement
1 parent328eea1 commit97fe5b8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

‎src/utils/pgut.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,9 +962,18 @@ pgut_strndup(const char *str, size_t n)
962962
if (str==NULL)
963963
returnNULL;
964964

965+
#if_POSIX_C_SOURCE >=200809L
965966
if ((ret=strndup(str,n))==NULL)
966967
elog(ERROR,"could not duplicate string \"%s\": %s",
967968
str,strerror(errno));
969+
#else/* WINDOWS doesn't have strndup() */
970+
if ((ret=malloc(n+1))==NULL)
971+
elog(ERROR,"could not duplicate string \"%s\": %s",
972+
str,strerror(errno));
973+
974+
memcpy(ret,str,n);
975+
ret[n]='\0';
976+
#endif
968977
returnret;
969978
}
970979

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp