summaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorPhilip Kelley <phkelley@hotmail.com>2014-04-22 10:21:19 -0400
committerPhilip Kelley <phkelley@hotmail.com>2014-04-23 09:23:50 -0400
commit7110000dd5b82c86863633ee37f72ac876a44476 (patch)
tree72a8e3ccc4ff2e3e016a3e97933ac44f7d557f0c /src/util.h
parent65477db1660273c453c590b8e3b97a4f7c41df61 (diff)
downloadlibgit2-7110000dd5b82c86863633ee37f72ac876a44476.tar.gz
React to feedback for UTF-8 <-> WCHAR and reparse work
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