Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libedit - call the mapping function directly instead of ...



details:   https://anonhg.NetBSD.org/src/rev/4f0f055e6da8
branches:  trunk
changeset: 750740:4f0f055e6da8
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Jan 12 19:40:50 2010 +0000

description:
- call the mapping function directly instead of el_wset().
- save the strings passed to the mapping function so that they don't get
  re-used. This leaks. To fix it properly we could either pass a flag to
  free particular entries before re-using, or allocate all of them.
  Allocating all of them wastes memory, allocating some of them makes
  the code more complex.
This fixes compatibility binding (shell tab completion for example)

diffstat:

 lib/libedit/eln.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (29 lines):

diff -r 6b22b574a42a -r 4f0f055e6da8 lib/libedit/eln.c
--- a/lib/libedit/eln.c Tue Jan 12 19:37:18 2010 +0000
+++ b/lib/libedit/eln.c Tue Jan 12 19:40:50 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: eln.c,v 1.3 2009/12/31 15:58:26 christos Exp $ */
+/*     $NetBSD: eln.c,v 1.4 2010/01/12 19:40:50 christos Exp $ */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: eln.c,v 1.3 2009/12/31 15:58:26 christos Exp $");
+__RCSID("$NetBSD: eln.c,v 1.4 2010/01/12 19:40:50 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include "histedit.h"
@@ -191,7 +191,9 @@
                    ret = -1;
                    goto out;
                }
-               ret = el_wset(el, op, wargv[0], wargv[1], func);
+               // XXX: The two strdup's leak
+               ret = map_addfunc(el, Strdup(wargv[0]), Strdup(wargv[1]),
+                   func);
                ct_free_argv(wargv);
                break;
        }



Home | Main Index | Thread Index | Old Index