diff options
author | Igor Ryzhov <iryzhov@nfware.com> | 2020-11-30 16:50:51 +0100 |
---|---|---|
committer | Igor Ryzhov <iryzhov@nfware.com> | 2020-11-30 16:55:40 +0100 |
commit | 6df43392d8703df6e92b7ae6e96373e6c3fc5083 (patch) | |
tree | 24694e9cbb47dcc06281f7da2b55b69f98380a74 /lib/memory.h | |
parent | vtysh: fix memory leak (diff) | |
download | frr-6df43392d8703df6e92b7ae6e96373e6c3fc5083.tar.xz frr-6df43392d8703df6e92b7ae6e96373e6c3fc5083.zip |
vtysh: fix incorrect memory statistics
As code comment states, 1 count of MTYPE_COMPLETION is leaked for each
autocompleted token. Let's manually decrement the counter before passing
the pointer to readline.
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib/memory.h')
-rw-r--r-- | lib/memory.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/memory.h b/lib/memory.h index 13f2f9b11..e9db12fce 100644 --- a/lib/memory.h +++ b/lib/memory.h @@ -162,12 +162,15 @@ extern void *qrealloc(struct memtype *mt, void *ptr, size_t size) __attribute__((_ALLOC_SIZE(3), nonnull(1) _RET_NONNULL)); extern void *qstrdup(struct memtype *mt, const char *str) __attribute__((malloc, nonnull(1) _RET_NONNULL)); +extern void qcountfree(struct memtype *mt, void *ptr) + __attribute__((nonnull(1))); extern void qfree(struct memtype *mt, void *ptr) __attribute__((nonnull(1))); #define XMALLOC(mtype, size) qmalloc(mtype, size) #define XCALLOC(mtype, size) qcalloc(mtype, size) #define XREALLOC(mtype, ptr, size) qrealloc(mtype, ptr, size) #define XSTRDUP(mtype, str) qstrdup(mtype, str) +#define XCOUNTFREE(mtype, ptr) qcountfree(mtype, ptr) #define XFREE(mtype, ptr) \ do { \ qfree(mtype, ptr); \ |