return str ? mt_checkalloc(mt, strdup(str), strlen(str) + 1) : NULL;
}
+void qcountfree(struct memtype *mt, void *ptr)
+{
+ if (ptr)
+ mt_count_free(mt, ptr);
+}
+
void qfree(struct memtype *mt, void *ptr)
{
if (ptr)
__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); \
cmd_free_strvec(vline);
}
- if (matched && matched[index])
- /*
- * this is free()'d by readline, but we leak 1 count of
- * MTYPE_COMPLETION
- */
+ if (matched && matched[index]) {
+ XCOUNTFREE(MTYPE_COMPLETION, matched[index]);
return matched[index++];
+ }
XFREE(MTYPE_TMP, matched);