From: Heikki Linnakangas Date: Fri, 9 Jan 2015 09:23:47 +0000 (+0200) Subject: Use common pg_str_endswith function X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=0f95976401680dd4c6bb2adabff8d2accdf288c3;p=users%2Fheikki%2Fpostgres.git Use common pg_str_endswith function --- diff --git a/contrib/pg_rewind/filemap.c b/contrib/pg_rewind/filemap.c index aca3f9349b..3d69100930 100644 --- a/contrib/pg_rewind/filemap.c +++ b/contrib/pg_rewind/filemap.c @@ -18,6 +18,7 @@ #include "filemap.h" #include "pg_rewind.h" +#include "common/string.h" #include "catalog/pg_tablespace.h" #include "storage/fd.h" @@ -53,18 +54,6 @@ filemap_create(void) return map; } -static bool -endswith(const char *haystack, const char *needle) -{ - int needlelen = strlen(needle); - int haystacklen = strlen(haystack); - - if (haystacklen < needlelen) - return false; - - return strcmp(&haystack[haystacklen - needlelen], needle) == 0; -} - /* * Callback for processing remote file list. */ @@ -181,7 +170,7 @@ process_remote_file(const char *path, file_type_t type, size_t newsize, * An exception: PG_VERSIONs should be identical, but avoid * overwriting it for paranoia. */ - if (endswith(path, "PG_VERSION")) + if (pg_str_endswith(path, "PG_VERSION")) { action = FILE_ACTION_NONE; oldsize = statbuf.st_size;