diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2021-03-07 15:31:41 +0100 |
---|---|---|
committer | Christian Göttsche <cgzones@googlemail.com> | 2021-03-17 15:54:17 +0100 |
commit | 1e806f9899600256cbcc540715261f461e11dd25 (patch) | |
tree | 292ef9c567e8a0c2b17758f25eab49120aebfcc1 /RichString.h | |
parent | d9f2eacbc5b3fccf63b24944ce9a30d762baea3c (diff) |
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
Diffstat (limited to 'RichString.h')
-rw-r--r-- | RichString.h | 13 |
1 files changed, 9 insertions, 4 deletions
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); |