From 885b1b7ded3d5ef5c78a6cf7a655897402e22c14 Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Fri, 6 Jun 2014 23:08:51 -0700 Subject: [PATCH] fix textedit_sample a bit --- tests/textedit_sample.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/textedit_sample.c b/tests/textedit_sample.c index 32cf287..48b0c4f 100644 --- a/tests/textedit_sample.c +++ b/tests/textedit_sample.c @@ -32,16 +32,17 @@ void layout_func(StbTexteditRow *row, STB_TEXTEDIT_STRING *str, int start_i) int delete_chars(STB_TEXTEDIT_STRING *str, int pos, int num) { - memmove(&str->string[pos], &str->string[pos+num], str->stringlen - (pos-num)); + memmove(&str->string[pos], &str->string[pos+num], str->stringlen - pos - num); str->stringlen -= num; return 1; // always succeeds } int insert_chars(STB_TEXTEDIT_STRING *str, int pos, STB_TEXTEDIT_CHARTYPE *newtext, int num) { - str->string = realloc(str, str->stringlen + num); + str->string = realloc(str->string, str->stringlen + num); memmove(&str->string[pos+num], &str->string[pos], str->stringlen - pos); memcpy(&str->string[pos], newtext, num); + str->stringlen += num; return 1; // always succeeds }