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.c | |
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.c')
-rw-r--r-- | RichString.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/RichString.c b/RichString.c index c4ecc258..558c7430 100644 --- a/RichString.c +++ b/RichString.c @@ -185,11 +185,11 @@ int RichString_findChar(const RichString* this, char c, int start) { #endif /* HAVE_LIBNCURSESW */ -void RichString_prune(RichString* this) { - if (this->chlen > RICHSTRING_MAXLEN) +void RichString_delete(RichString* this) { + if (this->chlen > RICHSTRING_MAXLEN) { free(this->chptr); - memset(this, 0, sizeof(RichString)); - this->chptr = this->chstr; + this->chptr = this->chstr; + } } void RichString_setAttr(RichString* this, int attrs) { |