From 18c014de6771a3032308123af9969c966e20b7c8 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 30 Jan 2018 14:33:01 +0100 Subject: utils: add helper wrapper for osmo_strlcpy() Add wrapper for osmo_strlcpy() which uses sizeof() to automatically determine buffer's size and use it for GSMTAP logging. This is pretty common use case for osmo_strlcpy() so it's a good idea to save some typing by using generic define. Related: OS#2864 Change-Id: I03d0d3d32a8d572ad573d03c603e14cdc27a3f7b --- include/osmocom/core/utils.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index 72266ae6..f1e011fe 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -26,6 +26,9 @@ /*! Number of bytes necessary to store given BITS */ #define OSMO_BYTES_FOR_BITS(BITS) ((BITS + 8 - 1) / 8) +/*! Copy a C-string into a sized buffer using sizeof to detect buffer's size */ +#define OSMO_STRLCPY_ARRAY(array, src) osmo_strlcpy(array, src, sizeof(array)) + #include #include #include -- cgit v1.2.3