Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libedit Fix memory leaks found by valgrind. From Julien ...
details: https://anonhg.NetBSD.org/src/rev/a49cf211b8bd
branches: trunk
changeset: 582812:a49cf211b8bd
user: christos <christos%NetBSD.org@localhost>
date: Wed Jul 06 21:13:02 2005 +0000
description:
Fix memory leaks found by valgrind. From Julien Torres
diffstat:
lib/libedit/history.c | 5 +++--
lib/libedit/key.c | 19 +++++++++++++------
2 files changed, 16 insertions(+), 8 deletions(-)
diffs (87 lines):
diff -r 7c1ecaafd26a -r a49cf211b8bd lib/libedit/history.c
--- a/lib/libedit/history.c Wed Jul 06 20:56:49 2005 +0000
+++ b/lib/libedit/history.c Wed Jul 06 21:13:02 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: history.c,v 1.28 2004/11/27 18:31:45 christos Exp $ */
+/* $NetBSD: history.c,v 1.29 2005/07/06 21:13:02 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: history.c,v 1.28 2004/11/27 18:31:45 christos Exp $");
+__RCSID("$NetBSD: history.c,v 1.29 2005/07/06 21:13:02 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -523,6 +523,7 @@
if (h->h_next == history_def_next)
history_def_clear(h->h_ref, &ev);
+ h_free(h);
}
diff -r 7c1ecaafd26a -r a49cf211b8bd lib/libedit/key.c
--- a/lib/libedit/key.c Wed Jul 06 20:56:49 2005 +0000
+++ b/lib/libedit/key.c Wed Jul 06 21:13:02 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: key.c,v 1.15 2003/10/18 23:48:42 christos Exp $ */
+/* $NetBSD: key.c,v 1.16 2005/07/06 21:13:02 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: key.c,v 1.15 2003/10/18 23:48:42 christos Exp $");
+__RCSID("$NetBSD: key.c,v 1.16 2005/07/06 21:13:02 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -85,6 +85,7 @@
private int node__try(EditLine *, key_node_t *, const char *,
key_value_t *, int);
private key_node_t *node__get(int);
+private void node__free(key_node_t *);
private void node__put(EditLine *, key_node_t *);
private int node__delete(EditLine *, key_node_t **, const char *);
private int node_lookup(EditLine *, const char *, key_node_t *,
@@ -110,7 +111,6 @@
return (0);
}
-
/* key_end():
* Free the key maps
*/
@@ -120,8 +120,7 @@
el_free((ptr_t) el->el_key.buf);
el->el_key.buf = NULL;
- /* XXX: provide a function to clear the keys */
- el->el_key.map = NULL;
+ node__free(el->el_key.map);
}
@@ -468,7 +467,15 @@
return (ptr);
}
-
+private void
+node__free(key_node_t *k)
+{
+ if (k == NULL)
+ return;
+ node__free(k->sibling);
+ node__free(k->next);
+ el_free((ptr_t) k);
+}
/* node_lookup():
* look for the str starting at node ptr.
Home |
Main Index |
Thread Index |
Old Index