json: Move from lib to include/openvswitch.
[cascardo/ovs.git] / lib / util.h
index f631bdf..5049d15 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "compiler.h"
+#include "util.h"
 #include "openvswitch/util.h"
 
 extern char *program_name;
@@ -112,6 +113,7 @@ void *xrealloc(void *, size_t);
 void *xmemdup(const void *, size_t) MALLOC_LIKE;
 char *xmemdup0(const char *, size_t) MALLOC_LIKE;
 char *xstrdup(const char *) MALLOC_LIKE;
+char *nullable_xstrdup(const char *) MALLOC_LIKE;
 char *xasprintf(const char *format, ...) OVS_PRINTF_FORMAT(1, 2) MALLOC_LIKE;
 char *xvasprintf(const char *format, va_list) OVS_PRINTF_FORMAT(1, 0) MALLOC_LIKE;
 void *x2nrealloc(void *p, size_t *n, size_t s);
@@ -392,37 +394,37 @@ void bitwise_toggle_bit(void *dst, unsigned int len, unsigned int ofs);
 
 /* Returns non-zero if the parameters have equal value. */
 static inline int
-ovs_u128_equals(const ovs_u128 *a, const ovs_u128 *b)
+ovs_u128_equals(const ovs_u128 a, const ovs_u128 b)
 {
-    return (a->u64.hi == b->u64.hi) && (a->u64.lo == b->u64.lo);
+    return (a.u64.hi == b.u64.hi) && (a.u64.lo == b.u64.lo);
 }
 
 /* Returns true if 'val' is 0. */
 static inline bool
-ovs_u128_is_zero(const ovs_u128 *val)
+ovs_u128_is_zero(const ovs_u128 val)
 {
-    return !(val->u64.hi || val->u64.lo);
+    return !(val.u64.hi || val.u64.lo);
 }
 
 /* Returns true if 'val' is all ones. */
 static inline bool
-ovs_u128_is_ones(const ovs_u128 *val)
+ovs_u128_is_ones(const ovs_u128 val)
 {
-    return ovs_u128_equals(val, &OVS_U128_MAX);
+    return ovs_u128_equals(val, OVS_U128_MAX);
 }
 
 /* Returns non-zero if the parameters have equal value. */
 static inline int
-ovs_be128_equals(const ovs_be128 *a, const ovs_be128 *b)
+ovs_be128_equals(const ovs_be128 a, const ovs_be128 b)
 {
-    return (a->be64.hi == b->be64.hi) && (a->be64.lo == b->be64.lo);
+    return (a.be64.hi == b.be64.hi) && (a.be64.lo == b.be64.lo);
 }
 
 /* Returns true if 'val' is 0. */
 static inline bool
-ovs_be128_is_zero(const ovs_be128 *val)
+ovs_be128_is_zero(const ovs_be128 val)
 {
-    return !(val->be64.hi || val->be64.lo);
+    return !(val.be64.hi || val.be64.lo);
 }
 
 static inline ovs_u128