1 /* Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. */
9 #include "error_handling/string_stream.h"
10 void ssinit(sstream_t
* stream
) {
15 void ssfree(sstream_t
* stream
) {
21 int ssvprintf(sstream_t
* stream
, const char* format
, va_list args
) {
27 len
= vsnprintf(NULL
, 0, format
, args
);
29 outstr
= malloc(stream
->length
+ len
+ 1);
31 memcpy(outstr
, stream
->data
, stream
->length
);
35 stream
->data
= outstr
;
36 vsprintf(&stream
->data
[stream
->length
], format
, hold
);
37 stream
->length
+= len
;
42 int ssprintf(sstream_t
* stream
, const char* format
, ...) {
45 va_start(args
, format
);
46 out
= ssvprintf(stream
, format
, args
);