av_bprint_alloc(buf, size_init - 1);
}
+void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size)
+{
+ buf->str = buffer;
+ buf->len = 0;
+ buf->size = size;
+ buf->size_max = size;
+ *buf->str = 0;
+}
+
void av_bprintf(AVBPrint *buf, const char *fmt, ...)
{
unsigned room;
av_bprint_grow(buf, n);
}
+void av_bprint_clear(AVBPrint *buf)
+{
+ if (buf->len) {
+ *buf->str = 0;
+ buf->len = 0;
+ }
+}
+
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
{
unsigned real_size = FFMIN(buf->len + 1, buf->size);
int main(void)
{
AVBPrint b;
+ char buf[256];
av_bprint_init(&b, 0, -1);
bprint_pascal(&b, 5);
- printf("Short text in unlimited buffer: %zu/%u\n", strlen(b.str), b.len);
+ printf("Short text in unlimited buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
printf("%s\n", b.str);
av_bprint_finalize(&b, NULL);
av_bprint_init(&b, 0, -1);
bprint_pascal(&b, 25);
- printf("Long text in unlimited buffer: %zu/%u\n", strlen(b.str), b.len);
+ printf("Long text in unlimited buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
av_bprint_finalize(&b, NULL);
av_bprint_init(&b, 0, 2048);
bprint_pascal(&b, 25);
- printf("Long text in limited buffer: %zu/%u\n", strlen(b.str), b.len);
+ printf("Long text in limited buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
av_bprint_finalize(&b, NULL);
av_bprint_init(&b, 0, 1);
bprint_pascal(&b, 5);
- printf("Short text in automatic buffer: %zu/%u\n", strlen(b.str), b.len);
+ printf("Short text in automatic buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
av_bprint_init(&b, 0, 1);
bprint_pascal(&b, 25);
- printf("Long text in automatic buffer: %zu/%u\n", strlen(b.str), b.len);
+ printf("Long text in automatic buffer: %u/%u\n", (unsigned)strlen(b.str)/8*8, b.len);
/* Note that the size of the automatic buffer is arch-dependant. */
av_bprint_init(&b, 0, 0);
bprint_pascal(&b, 25);
- printf("Long text count only buffer: %zu/%u\n", strlen(b.str), b.len);
+ printf("Long text count only buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
+
+ av_bprint_init_for_buffer(&b, buf, sizeof(buf));
+ bprint_pascal(&b, 25);
+ printf("Long text count only buffer: %u/%u\n", (unsigned)strlen(buf), b.len);
return 0;
}