]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: clean up tab-completion memory counting
authorDavid Lamparter <equinox@opensourcerouting.org>
Thu, 26 Jan 2017 20:57:24 +0000 (21:57 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Tue, 31 Jan 2017 14:28:19 +0000 (15:28 +0100)
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/vector.c
lib/vector.h
lib/vty.c
tests/test-commands.c
vtysh/vtysh.c

index 03ad3171d6603857a2b23b21d06bbf8f96344613..0b1d5d5046ff45d09549d7385086ec5c0107ae12 100644 (file)
@@ -25,7 +25,7 @@
 #include "memory.h"
 
 DEFINE_MTYPE_STATIC(LIB, VECTOR,       "Vector")
-DEFINE_MTYPE(       LIB, VECTOR_INDEX, "Vector index")
+DEFINE_MTYPE_STATIC(LIB, VECTOR_INDEX, "Vector index")
 
 /* Initialize vector : allocate memory and return vector. */
 vector
@@ -43,18 +43,6 @@ vector_init (unsigned int size)
   return v;
 }
 
-void
-vector_only_wrapper_free (vector v)
-{
-  XFREE (MTYPE_VECTOR, v);
-}
-
-void
-vector_only_index_free (void *index)
-{
-  XFREE (MTYPE_VECTOR_INDEX, index);
-}
-
 void
 vector_free (vector v)
 {
index d8f4c78608ccb5f6516c927f3fe7d1c9b55084ed..28f4ad320ff435542032bd9f0e0843f0a9e0c084 100644 (file)
@@ -24,7 +24,6 @@
 #define _ZEBRA_VECTOR_H
 
 #include "memory.h"
-DECLARE_MTYPE(VECTOR_INDEX)
 
 /* struct for vector */
 struct _vector 
@@ -55,8 +54,6 @@ extern int vector_set (vector v, void *val);
 extern int vector_set_index (vector v, unsigned int i, void *val);
 extern void vector_unset (vector v, unsigned int i);
 extern unsigned int vector_count (vector v);
-extern void vector_only_wrapper_free (vector v);
-extern void vector_only_index_free (void *index);
 extern void vector_free (vector v);
 extern vector vector_copy (vector v);
 
index 9413d003efac8383fa76274b094bbdd7da97e4d1..e70079c52dd63bd1625b1f5319008c82a58e351d 100644 (file)
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -962,8 +962,6 @@ vty_complete_command (struct vty *vty)
       vty_backward_pure_word (vty);
       vty_insert_word_overwrite (vty, matched[0]);
       XFREE (MTYPE_TMP, matched[0]);
-      vector_only_index_free (matched);
-      return;
       break;
     case CMD_COMPLETE_LIST_MATCH:
       for (i = 0; matched[i] != NULL; i++)
@@ -986,7 +984,7 @@ vty_complete_command (struct vty *vty)
       break;
     }
   if (matched)
-    vector_only_index_free (matched);
+    XFREE (MTYPE_TMP, matched);
 }
 
 static void
index c0bc39f88f87c483bd92979ef7436410fc3bde31..c86ffc5891c05ac53e0413ee8f8557d55bbeb902 100644 (file)
@@ -317,7 +317,7 @@ test_run(struct prng *prng, struct vty *vty, const char *cmd, unsigned int edit_
                 printf("  '%s'\n", completions[j]);
                 XFREE(MTYPE_TMP, completions[j]);
               }
-            XFREE(MTYPE_VECTOR_INDEX, completions);
+            XFREE(MTYPE_TMP, completions);
           }
 
         vty->node = cnode->node;
index 1db3dca3521a5f1930db857bdb373468176b437b..f15f051e69688cd1f16e09571bd2ab82ccff596d 100644 (file)
@@ -828,8 +828,6 @@ command_generator (const char *text, int state)
       if (rl_end && isspace ((int) rl_line_buffer[rl_end - 1]))
        vector_set (vline, NULL);
 
-      if (matched)
-        XFREE (MTYPE_TMP, matched);
       matched = cmd_complete_command (vline, vty, &complete_status);
       cmd_free_strvec (vline);
     }
@@ -837,6 +835,9 @@ command_generator (const char *text, int state)
   if (matched && matched[index])
     return matched[index++];
 
+  XFREE (MTYPE_TMP, matched);
+  matched = NULL;
+
   return NULL;
 }