summaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorVicent Marti <vicent@github.com>2014-04-23 07:13:49 -0700
committerVicent Marti <vicent@github.com>2014-04-23 07:13:49 -0700
commit5ca410b9a9bc30a65ed0125646b3702d5943100b (patch)
tree7c352c4382def6eaee007745f3f932659b10d827 /src/util.h
parent5b58d6f78cf8346445374eaf5cde0f54be5c5796 (diff)
parent7110000dd5b82c86863633ee37f72ac876a44476 (diff)
downloadlibgit2-5ca410b9a9bc30a65ed0125646b3702d5943100b.tar.gz
Merge pull request #2283 from phkelley/win32_fs
Win32: UTF-8 <-> WCHAR conversion overhaul
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
index d94463c65..6fb2dc0f4 100644
--- a/src/util.h
+++ b/src/util.h
@@ -22,6 +22,15 @@
#define GIT_DATE_RFC2822_SZ 32
+/**
+ * Return the length of a constant string.
+ * We are aware that `strlen` performs the same task and is usually
+ * optimized away by the compiler, whilst being safer because it returns
+ * valid values when passed a pointer instead of a constant string; however
+ * this macro will transparently work with wide-char and single-char strings.
+ */
+#define CONST_STRLEN(x) ((sizeof(x)/sizeof(x[0])) - 1)
+
/*
* Custom memory allocation wrappers
* that set error code and error message