diff options
Diffstat (limited to 'client/libacron/private/helpers.h')
-rw-r--r-- | client/libacron/private/helpers.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/client/libacron/private/helpers.h b/client/libacron/private/helpers.h index 20dfeec..f1635a6 100644 --- a/client/libacron/private/helpers.h +++ b/client/libacron/private/helpers.h @@ -9,14 +9,37 @@ #define SALLOC(s, out) alloc(NULL, 1, sizeof(s), true, (void **) out) +/** + * Allocate or reallocate a range of memory on heap. + * @param existing The existing range to extend. NULL-able. + * @param count The number of bytes. Final size = count * bytes. + * @param bytes The size. Final size = count * bytes. + * @param zero_out Whether to zero out the newly-allocated memory. Ignored when existing != NULL. + * @param out Output memory range. Not NULL if the return value is AC_E_OK. + * @return AC_E_OK or an error code. When failed, *out is untouched. + * MT-Safe + */ int alloc(void *existing, unsigned int count, unsigned int bytes, bool zero_out, void **out); +/** + * Duplicate a string. + * @param str String to duplicate. + * @param out Output string. Not NULL if the return value is AC_E_OK. + * @return AC_E_OK or an error code. When failed, *out is untouched. + * MT-Safe + */ int strdup2(const char *str, char **out); +/** + * Cross-platform thread-safe wrapper of strerror(3). + * @param errnum errno + * @return Always non-NULL error message. + * MT-Safe + */ char *strerror2(int errnum); #endif /* LIBAC_HELPERS_H */ |