Use common pg_str_endswith function
authorHeikki Linnakangas <[email protected]>
Fri, 9 Jan 2015 09:23:47 +0000 (11:23 +0200)
committerHeikki Linnakangas <[email protected]>
Fri, 16 Jan 2015 11:37:07 +0000 (13:37 +0200)
contrib/pg_rewind/filemap.c

index aca3f9349b9188b5c9b466118633b5aa33772e06..3d6910093052cce954bf6ff8bbecca34c531b972 100644 (file)
@@ -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;