diff options
author | Florian Weimer <fweimer@redhat.com> | 2022-12-19 18:56:55 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2022-12-19 18:56:55 +0100 |
commit | af7f4165512ea242b5f711ee03a04f6afe22232d (patch) | |
tree | c4fd7778fa2e513af3105bc97eccddbb60d31ef7 /include | |
parent | fb9bd841b8e8b22a42fd68c56355c2ddd211db21 (diff) | |
download | glibc-af7f4165512ea242b5f711ee03a04f6afe22232d.tar.gz glibc-af7f4165512ea242b5f711ee03a04f6afe22232d.tar.xz glibc-af7f4165512ea242b5f711ee03a04f6afe22232d.zip |
libio: Convert __vasprintf_internal to buffers
The buffer resizing algorithm is slightly different. The initial buffer is on the stack, and small buffers are directly allocated on the heap using the exact required size. The overhead of the additional copy is compensated by the lowered setup cost for buffers compared to libio streams. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/printf_buffer.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/printf_buffer.h b/include/printf_buffer.h index cc9f8e5346..c8e22e1e90 100644 --- a/include/printf_buffer.h +++ b/include/printf_buffer.h @@ -49,6 +49,7 @@ enum __printf_buffer_mode __printf_buffer_mode_snprintf, __printf_buffer_mode_sprintf_chk, __printf_buffer_mode_to_file, + __printf_buffer_mode_asprintf, __printf_buffer_mode_strfmon, __printf_buffer_mode_fp, /* For __printf_fp_l_buffer. */ __printf_buffer_mode_fp_to_wide, /* For __wprintf_fp_l_buffer. */ @@ -304,6 +305,9 @@ void __printf_buffer_flush_snprintf (struct __printf_buffer_snprintf *) struct __printf_buffer_to_file; void __printf_buffer_flush_to_file (struct __printf_buffer_to_file *) attribute_hidden; +struct __printf_buffer_asprintf; +void __printf_buffer_flush_asprintf (struct __printf_buffer_asprintf *) + attribute_hidden; struct __printf_buffer_fp; void __printf_buffer_flush_fp (struct __printf_buffer_fp *) attribute_hidden; @@ -332,4 +336,9 @@ void __wprintf_buffer_flush_to_file (struct __wprintf_buffer_to_file *) /* Temporary buffer used during floating point digit translation. */ #define PRINTF_BUFFER_SIZE_DIGITS 64 +/* Size of the initial on-stack buffer for asprintf. It should be + large enough to copy almost all asprintf usages with just a single + (final, correctly sized) heap allocation. */ +#define PRINTF_BUFFER_SIZE_ASPRINTF 200 + #endif /* PRINTF_BUFFER_H */ |