summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-03-14 14:26:12 +0100
committerThomas Haller <thaller@redhat.com>2014-04-03 10:55:54 +0200
commita72079a862af122494d06b44550d650720b439e4 (patch)
tree41c2685e204d0bf5e0861d01f27bcc461bc071f8
parent408ecd6b5fe9cb09f2177e8e0010a044ea4aa309 (diff)
downloadNetworkManager-a72079a862af122494d06b44550d650720b439e4.tar.gz
core: add macro STRLEN
Returns the length of a string at compile time. Contrary to strlen(), which is a run time expression -- even if the compler might be able to optimize strlen() for string constants. Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--src/NetworkManagerUtils.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/NetworkManagerUtils.h b/src/NetworkManagerUtils.h
index f9583f5f5d..cf55b07790 100644
--- a/src/NetworkManagerUtils.h
+++ b/src/NetworkManagerUtils.h
@@ -40,6 +40,9 @@ void nm_utils_ip6_address_clear_host_address (struct in6_addr *dst, const struct
int nm_spawn_process (const char *args);
+/* macro to return strlen() of a compile time string. */
+#define STRLEN(str) ( sizeof ("" str) - 1 )
+
gboolean nm_match_spec_string (const GSList *specs, const char *string);
gboolean nm_match_spec_hwaddr (const GSList *specs, const char *hwaddr);
gboolean nm_match_spec_s390_subchannels (const GSList *specs, const char *subchannels);