#include <stdio.h>
char *
-bb_vprintf_at(bb_t *bb, uns ofs, const char *fmt, va_list args)
+bb_vprintf_at(bb_t *bb, size_t ofs, const char *fmt, va_list args)
{
bb_grow(bb, ofs + 1);
va_list args2;
}
char *
-bb_printf_at(bb_t *bb, uns ofs, const char *fmt, ...)
+bb_printf_at(bb_t *bb, size_t ofs, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
* See @bb_printf().
**/
char *bb_vprintf(bb_t *bb, const char *fmt, va_list args);
+
/**
* printf() into a growing buffer.
* Generates a `'\0'`-terminated string at the beginning of the buffer
* See @bb_vprintf().
**/
char *bb_printf(bb_t *bb, const char *fmt, ...);
+
/**
* Like @bb_vprintf(), but it does not start at the beginning of the
* buffer, but @ofs bytes further.
* Returns pointer to the new string (eg. @ofs bytes after the
* beginning of buffer).
**/
-char *bb_vprintf_at(bb_t *bb, uns ofs, const char *fmt, va_list args);
+char *bb_vprintf_at(bb_t *bb, size_t ofs, const char *fmt, va_list args);
+
/**
* Like @bb_vprintf_at(), but it takes individual arguments.
**/
-char *bb_printf_at(bb_t *bb, uns ofs, const char *fmt, ...);
+char *bb_printf_at(bb_t *bb, size_t ofs, const char *fmt, ...);
#endif
* length of available memory.
**/
typedef struct BUF_T {
- uns len;
+ size_t len;
GBUF_TYPE *ptr;
} BUF_T;
* Use <<fun__GENERIC_LINK_|GBUF_PREFIX|grow|,`GBUF_PREFIX(grow)()`>>
* for growing.
**/
-static void UNUSED GBUF_PREFIX(set_size)(BUF_T *b, uns len)
+static void UNUSED GBUF_PREFIX(set_size)(BUF_T *b, size_t len)
{
b->len = len;
b->ptr = xrealloc(b->ptr, len * sizeof(GBUF_TYPE));
#ifdef GBUF_TRACE
- GBUF_TRACE(STRINGIFY_EXPANDED(BUF_T) " growing to %u items", len);
+ GBUF_TRACE(STRINGIFY_EXPANDED(BUF_T) " growing to %zu items", len);
#endif
}
-static void UNUSED GBUF_PREFIX(do_grow)(BUF_T *b, uns len)
+static void UNUSED GBUF_PREFIX(do_grow)(BUF_T *b, size_t len)
{
if (len < 2*b->len) // to ensure logarithmic cost
len = 2*b->len;
* any more) by
* <<fun__GENERIC_LINK_|GBUF_PREFIX|set_size|,`GBUF_PREFIX(set_size)()`>>.
**/
-static inline GBUF_TYPE *GBUF_PREFIX(grow)(BUF_T *b, uns len)
+static inline GBUF_TYPE *GBUF_PREFIX(grow)(BUF_T *b, size_t len)
{
if (unlikely(len > b->len))
GBUF_PREFIX(do_grow)(b, len);