diff --git a/src/libratbag-util.h b/src/libratbag-util.h index 93897c60..ad9640b0 100644 --- a/src/libratbag-util.h +++ b/src/libratbag-util.h @@ -25,6 +25,7 @@ #define LIBRATBAG_UTIL_H #include +#include #include #include @@ -78,6 +79,14 @@ int list_empty(const struct list *list); #define streq(s1, s2) (strcmp((s1), (s2)) == 0) #define strneq(s1, s2, n) (strncmp((s1), (s2), (n)) == 0) +static inline char* +strncpy_safe(char *dest, const char *src, size_t n) +{ + strncpy(dest, src, n); + dest[n - 1] = '\0'; + return dest; +} + #define LIBRATBAG_EXPORT __attribute__ ((visibility("default"))) static inline void *