]> git.ipfire.org Git - thirdparty/git.git/blobdiff - git-compat-util.h
Fixed GPF in fast-import caused by unterminated linked list.
[thirdparty/git.git] / git-compat-util.h
index b3d4cf532e5728e6b962d0d65789f6e8e4bd7fe5..b2e18954c03ff502053cb74d142faab7d2a8dacb 100644 (file)
@@ -79,6 +79,11 @@ extern void gitunsetenv(const char *);
 extern char *gitstrcasestr(const char *haystack, const char *needle);
 #endif
 
+#ifdef NO_STRLCPY
+#define strlcpy gitstrlcpy
+extern size_t gitstrlcpy(char *, const char *, size_t);
+#endif
+
 static inline void *xmalloc(size_t size)
 {
        void *ret = malloc(size);
@@ -86,6 +91,9 @@ static inline void *xmalloc(size_t size)
                ret = malloc(1);
        if (!ret)
                die("Out of memory, malloc failed");
+#ifdef XMALLOC_POISON
+       memset(ret, 0xA5, size);
+#endif
        return ret;
 }
 
@@ -131,6 +139,13 @@ static inline ssize_t xwrite(int fd, const void *buf, size_t len)
        }
 }
 
+static inline int has_extension(const char *filename, const char *ext)
+{
+       size_t len = strlen(filename);
+       size_t extlen = strlen(ext);
+       return len > extlen && !memcmp(filename + len - extlen, ext, extlen);
+}
+
 /* Sane ctype - no locale, and works with signed chars */
 #undef isspace
 #undef isdigit