- * \sa printf(3). */
-#define PARA_VSPRINTF(fmt, p) \
-{ \
- int n; \
- size_t size = 100; \
- p = para_malloc(size); \
- while (1) { \
- va_list ap; \
- /* Try to print in the allocated space. */ \
- va_start(ap, fmt); \
- n = vsnprintf(p, size, fmt, ap); \
- va_end(ap); \
- /* If that worked, return the string. */ \
- if (n > -1 && n < size) \
- break; \
- /* Else try again with more space. */ \
- if (n > -1) /* glibc 2.1 */ \
- size = n + 1; /* precisely what is needed */ \
- else /* glibc 2.0 */ \
- size *= 2; /* twice the old size */ \
- p = para_realloc(p, size); \
- } \
+ * \return An integer between zero and \p max - 1, inclusively.
+ */
+_static_inline_ long int para_random(unsigned max)
+{
+ return ((max + 0.0) * (random() / (RAND_MAX + 1.0)));