diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2025-08-12 00:35:18 +0200 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2025-08-12 00:36:14 +0200 |
commit | 5dd98385e03b9cc7c912b1b50f7c406df117a9af (patch) | |
tree | 2fb914bac78ce8cfe77455ae47d710a4cbd0d1db /src/piece-table.h | |
parent | 85088f13c5653174c27f54faac5afd89fbb10655 (diff) |
piece-table: Don't allocate in piece_table_to_string
`piece_table_to_string` now receives a buffer and we also provide a
function that returns the length of the piece table.
TODO: the `piece_table_to_string` adds null termination, that makes the
buffer needed `piece_table_length(pt) + 1`. This we should document or
do more obvious.
Diffstat (limited to 'src/piece-table.h')
-rw-r--r-- | src/piece-table.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/piece-table.h b/src/piece-table.h index c9d6601..e90d2fa 100644 --- a/src/piece-table.h +++ b/src/piece-table.h @@ -29,6 +29,7 @@ char piece_table_index (piece_table *pt, size_t pos); void piece_table_insert (piece_table *pt, size_t pos, char *in, size_t len); void piece_table_delete (piece_table *pt, size_t pos, size_t len); -char *piece_table_to_string (piece_table *pt); +void piece_table_to_string (piece_table *pt, char *buf); +size_t piece_table_length (piece_table *pt); #endif |