From cdd4ef7d6ad6db6a8ca70c00915df7aa24fa74c6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 7 Apr 2022 15:43:23 +1000 Subject: Cleanup: pass the buffer length into `txt_insert_buf` Also remove redundant NULL check. --- source/blender/editors/space_text/text_autocomplete.c | 3 ++- source/blender/editors/space_text/text_ops.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'source/blender/editors/space_text') diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c index 55873740491..54735a4d481 100644 --- a/source/blender/editors/space_text/text_autocomplete.c +++ b/source/blender/editors/space_text/text_autocomplete.c @@ -267,7 +267,8 @@ static void confirm_suggestion(Text *text) // for (i = 0; i < skipleft; i++) // txt_move_left(text, 0); BLI_assert(memcmp(sel->name, &line[i], over) == 0); - txt_insert_buf(text, sel->name + over); + const char *buf = sel->name + over; + txt_insert_buf(text, buf, strlen(buf)); // for (i = 0; i < skipleft; i++) // txt_move_right(text, 0); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index d4aac8dd57f..3f1483bbd03 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -921,7 +921,7 @@ static int text_paste_exec(bContext *C, wmOperator *op) buf = new_buf; } - txt_insert_buf(text, buf); + txt_insert_buf(text, buf, buf_len); text_update_edited(text); MEM_freeN(buf); @@ -3587,7 +3587,7 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode) if (found) { if (mode == TEXT_REPLACE) { ED_text_undo_push_init(C); - txt_insert_buf(text, st->replacestr); + txt_insert_buf(text, st->replacestr, strlen(st->replacestr)); if (text->curl && text->curl->format) { MEM_freeN(text->curl->format); text->curl->format = NULL; @@ -3671,7 +3671,7 @@ static int text_replace_all(bContext *C) ED_text_undo_push_init(C); do { - txt_insert_buf(text, st->replacestr); + txt_insert_buf(text, st->replacestr, strlen(st->replacestr)); if (text->curl && text->curl->format) { MEM_freeN(text->curl->format); text->curl->format = NULL; -- cgit v1.2.3