From 1e806f9899600256cbcc540715261f461e11dd25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sun, 7 Mar 2021 15:31:41 +0100 Subject: RichString: do not unnecessarily clean whole buffer The local stack buffer does not need to be cleaned to zeros when - just initialized, cause the length is set to 0 and the first character is set to '\0', so all printing functions will safely stop - no further used, i.e. the variable goes out of scope --- RichString.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'RichString.h') diff --git a/RichString.h b/RichString.h index 497d0d2f..76323e40 100644 --- a/RichString.h +++ b/RichString.h @@ -16,8 +16,13 @@ in the source distribution for its full text. #define RichString_sizeVal(this) ((this).chlen) #define RichString_begin(this) RichString (this); RichString_beginAllocated(this) -#define RichString_beginAllocated(this) do { memset(&(this), 0, sizeof(RichString)); (this).chptr = (this).chstr; } while(0) -#define RichString_end(this) RichString_prune(&(this)) +#define RichString_beginAllocated(this) \ + do { \ + (this).chlen = 0, \ + (this).chptr = (this).chstr; \ + RichString_setChar(&this, 0, 0); \ + (this).highlightAttr = 0; \ + } while(0) #ifdef HAVE_LIBNCURSESW #define RichString_printVal(this, y, x) mvadd_wchstr(y, x, (this).chptr) @@ -42,14 +47,14 @@ typedef struct RichString_ { int highlightAttr; } RichString; +void RichString_delete(RichString* this); + void RichString_rewind(RichString* this, int count); void RichString_setAttrn(RichString* this, int attrs, int start, int charcount); int RichString_findChar(const RichString* this, char c, int start); -void RichString_prune(RichString* this); - void RichString_setAttr(RichString* this, int attrs); void RichString_appendChr(RichString* this, int attrs, char c, int count); -- cgit v1.2.3