shl_dup() duplicates a memory region similar to strdup() but without
reading the data length via strlen().
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
return 0;
}
+static inline int shl_dup(void **out, const void *data, size_t size)
+{
+ void *cpy;
+
+ if (!data || !size)
+ return -EINVAL;
+
+ cpy = malloc(size);
+ if (!cpy)
+ return -ENOMEM;
+
+ memcpy(cpy, data, size);
+ *out = cpy;
+ return 0;
+}
+
/* TODO: xkbcommon should provide these flags!
* We currently copy them into each library API we use so we need to keep
* them in sync. Currently, they're used in uterm-input and tsm-vte. */