/* Round 'v' up to the next 'alignment'-byte aligned boundary. 'alignment' must
* be a power of 2. */
+#undef ALIGN /* NetBSD <sys/param.h> defines this already */
#define ALIGN(v, alignment) (((v) + ((alignment) - 1)) & ~((alignment) - 1))
/* Maximum number of bytes that can be allocated on the stack.
* Memory allocation
*******************/
-extern void *
-wimlib_malloc(size_t size) _malloc_attribute;
+void *
+wimlib_malloc(size_t size);
-extern void
+void
wimlib_free_memory(void *p);
-extern void *
+void *
wimlib_realloc(void *ptr, size_t size);
-extern void *
-wimlib_calloc(size_t nmemb, size_t size) _malloc_attribute;
+void *
+wimlib_calloc(size_t nmemb, size_t size);
-extern char *
-wimlib_strdup(const char *str) _malloc_attribute;
+char *
+wimlib_strdup(const char *str);
-#ifdef __WIN32__
-extern wchar_t *
-wimlib_wcsdup(const wchar_t *str) _malloc_attribute;
+#ifdef _WIN32
+wchar_t *
+wimlib_wcsdup(const wchar_t *str);
#endif
-extern void *
-wimlib_aligned_malloc(size_t size, size_t alignment) _malloc_attribute;
+void *
+wimlib_aligned_malloc(size_t size, size_t alignment);
-extern void
+void
wimlib_aligned_free(void *ptr);
-extern void *
-memdup(const void *mem, size_t size) _malloc_attribute;
+void *
+memdup(const void *mem, size_t size);
#define MALLOC wimlib_malloc
#define FREE wimlib_free_memory
*******************/
#ifndef HAVE_MEMPCPY
-extern void *
+void *
mempcpy(void *dst, const void *src, size_t n);
#endif
-extern void
-randomize_byte_array(u8 *p, size_t n);
+/**************************
+ * Random number generation
+ **************************/
-extern void
-randomize_char_array_with_alnum(tchar *p, size_t n);
+void
+get_random_bytes(void *p, size_t n);
+
+void
+get_random_alnum_chars(tchar *p, size_t n);
/************************
* Hashing and comparison
return n * 0x9e37fffffffc0001ULL;
}
+static inline int
+cmp_u32(u32 n1, u32 n2)
+{
+ if (n1 < n2)
+ return -1;
+ if (n1 > n2)
+ return 1;
+ return 0;
+}
+
static inline int
cmp_u64(u64 n1, u64 n2)
{