From fee7ed20badc1015273c36776aa84cc04fc9307a Mon Sep 17 00:00:00 2001 From: seleznevae Date: Wed, 2 Jan 2019 09:42:32 +0300 Subject: [PATCH] [F] Fixed logic errors --- lib/fort.c | 12 ++++++------ src/string_buffer.c | 8 ++++---- src/string_buffer.h | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/fort.c b/lib/fort.c index 8155e19..ba955dc 100644 --- a/lib/fort.c +++ b/lib/fort.c @@ -338,7 +338,7 @@ FT_INTERNAL void destroy_string_buffer(string_buffer_t *buffer); FT_INTERNAL -string_buffer_t *copy_string_buffer(string_buffer_t *buffer); +string_buffer_t *copy_string_buffer(const string_buffer_t *buffer); FT_INTERNAL fort_status_t realloc_string_buffer_without_copy(string_buffer_t *buffer); @@ -352,7 +352,7 @@ fort_status_t fill_buffer_from_wstring(string_buffer_t *buffer, const wchar_t *s #endif /* FT_HAVE_WCHAR */ FT_INTERNAL -size_t buffer_text_height(string_buffer_t *buffer); +size_t buffer_text_height(const string_buffer_t *buffer); FT_INTERNAL size_t string_buffer_capacity(const string_buffer_t *buffer); @@ -4846,7 +4846,7 @@ void destroy_string_buffer(string_buffer_t *buffer) } FT_INTERNAL -string_buffer_t *copy_string_buffer(string_buffer_t *buffer) +string_buffer_t *copy_string_buffer(const string_buffer_t *buffer) { assert(buffer); string_buffer_t *result = create_string_buffer(buffer->data_sz, buffer->type); @@ -4855,14 +4855,14 @@ string_buffer_t *copy_string_buffer(string_buffer_t *buffer) switch (buffer->type) { case CharBuf: if (FT_IS_ERROR(fill_buffer_from_string(result, buffer->str.cstr))) { - destroy_string_buffer(buffer); + destroy_string_buffer(result); return NULL; } break; #ifdef FT_HAVE_WCHAR case WCharBuf: if (FT_IS_ERROR(fill_buffer_from_wstring(result, buffer->str.wstr))) { - destroy_string_buffer(buffer); + destroy_string_buffer(result); return NULL; } break; @@ -4928,7 +4928,7 @@ fort_status_t fill_buffer_from_wstring(string_buffer_t *buffer, const wchar_t *s FT_INTERNAL -size_t buffer_text_height(string_buffer_t *buffer) +size_t buffer_text_height(const string_buffer_t *buffer) { if (buffer == NULL || buffer->str.data == NULL || buf_str_len(buffer) == 0) { return 0; diff --git a/src/string_buffer.c b/src/string_buffer.c index 8994358..6eb0503 100644 --- a/src/string_buffer.c +++ b/src/string_buffer.c @@ -195,7 +195,7 @@ void destroy_string_buffer(string_buffer_t *buffer) } FT_INTERNAL -string_buffer_t *copy_string_buffer(string_buffer_t *buffer) +string_buffer_t *copy_string_buffer(const string_buffer_t *buffer) { assert(buffer); string_buffer_t *result = create_string_buffer(buffer->data_sz, buffer->type); @@ -204,14 +204,14 @@ string_buffer_t *copy_string_buffer(string_buffer_t *buffer) switch (buffer->type) { case CharBuf: if (FT_IS_ERROR(fill_buffer_from_string(result, buffer->str.cstr))) { - destroy_string_buffer(buffer); + destroy_string_buffer(result); return NULL; } break; #ifdef FT_HAVE_WCHAR case WCharBuf: if (FT_IS_ERROR(fill_buffer_from_wstring(result, buffer->str.wstr))) { - destroy_string_buffer(buffer); + destroy_string_buffer(result); return NULL; } break; @@ -277,7 +277,7 @@ fort_status_t fill_buffer_from_wstring(string_buffer_t *buffer, const wchar_t *s FT_INTERNAL -size_t buffer_text_height(string_buffer_t *buffer) +size_t buffer_text_height(const string_buffer_t *buffer) { if (buffer == NULL || buffer->str.data == NULL || buf_str_len(buffer) == 0) { return 0; diff --git a/src/string_buffer.h b/src/string_buffer.h index 8632acb..764fd60 100644 --- a/src/string_buffer.h +++ b/src/string_buffer.h @@ -31,7 +31,7 @@ FT_INTERNAL void destroy_string_buffer(string_buffer_t *buffer); FT_INTERNAL -string_buffer_t *copy_string_buffer(string_buffer_t *buffer); +string_buffer_t *copy_string_buffer(const string_buffer_t *buffer); FT_INTERNAL fort_status_t realloc_string_buffer_without_copy(string_buffer_t *buffer); @@ -45,7 +45,7 @@ fort_status_t fill_buffer_from_wstring(string_buffer_t *buffer, const wchar_t *s #endif /* FT_HAVE_WCHAR */ FT_INTERNAL -size_t buffer_text_height(string_buffer_t *buffer); +size_t buffer_text_height(const string_buffer_t *buffer); FT_INTERNAL size_t string_buffer_capacity(const string_buffer_t *buffer);