diff options
author | Thomas Haller <thaller@redhat.com> | 2014-03-14 14:26:12 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-03-27 10:10:10 +0100 |
commit | d46e1eb67d3140e6a73f3b5398bc073ed43c3277 (patch) | |
tree | b9891e4ae282041a47885548ae78c9e2fb863e7a | |
parent | 4dba720d8c883549e57a292a236c8ea44e1e0bca (diff) | |
download | NetworkManager-d46e1eb67d3140e6a73f3b5398bc073ed43c3277.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.h | 3 |
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); |