* tests/fill_memory.c: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.
* tests/quotactl.h (fill_memory, fill_memory_ex): Move to fill_memory.c.
* tests/tests.h (fill_memory, fill_memory_ex): New prototypes.
libtests_a_SOURCES = \
errno2name.c \
error_msg.c \
+ fill_memory.c \
get_page_size.c \
hexdump_strdup.c \
hexquote_strndup.c \
--- /dev/null
+#include "tests.h"
+
+void
+fill_memory_ex(char *ptr, size_t size, unsigned char start,
+ unsigned char period)
+{
+ size_t i;
+
+ for (i = 0; i < size; i++) {
+ ptr[i] = start + i % period;
+ }
+}
+
+void
+fill_memory(char *ptr, size_t size)
+{
+ fill_memory_ex(ptr, size, 0x80, 0x80);
+}
};
-static inline void
-fill_memory_ex(char *ptr, size_t size, unsigned char start,
- unsigned char period)
-{
- size_t i;
-
- for (i = 0; i < size; i++) {
- ptr[i] = start + i % period;
- }
-}
-
-static inline void
-fill_memory(char *ptr, size_t size)
-{
- fill_memory_ex(ptr, size, 0x80, 0x80);
-}
-
static inline void
check_quota(uint32_t flags, int cmd, const char *cmd_str,
const char *special, const char *special_str, ...)
void *tail_memdup(const void *, const size_t)
ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE((2));
+/*
+ * Fill memory (pointed by ptr, having size bytes) with different bytes (with
+ * values starting with start and resetting every period) in order to catch
+ * sign, byte order and/or alignment errors.
+ */
+void fill_memory_ex(char *ptr, size_t size, unsigned char start,
+ unsigned char period);
+/* Shortcut for fill_memory_ex(ptr, size, 0x80, 0x80) */
+void fill_memory(char *ptr, size_t size);
+
/* Close stdin, move stdout to a non-standard descriptor, and print. */
void tprintf(const char *, ...)
ATTRIBUTE_FORMAT((printf, 1, 2));