commit fd32de627c3e2e0e851fc2c3e044bb0e0e0ecf5c
parent 00742a530748777c1e68549af07a5ecda60bfe2b
Author: Claudio Alessi <smoppy@gmail.com>
Date: Wed, 13 Apr 2016 23:17:23 +0200
Improve viewdb() and viewtable() routines.
Fix few memory leaks along the way.
Diffstat:
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/myadm.c b/myadm.c
@@ -651,15 +651,14 @@ usage(void) {
void
viewdb(const Arg *arg) {
- View *v;
+ Item *choice = getitem(0);
- v = newaview("tables", viewdb_show);
- if(!(v->choice && v->choice->ncols)) {
+ if(!(choice && choice->ncols)) {
ui_set("status", "No database selected.");
return;
}
- mysql_select_db(mysql, v->choice->cols[0]);
- selview = v;
+ mysql_select_db(mysql, choice->cols[0]);
+ selview = newaview("tables", viewdb_show);
viewdb_show();
}
@@ -708,14 +707,13 @@ viewprev(const Arg *arg) {
void
viewtable(const Arg *arg) {
- View *v;
+ Item *choice = getitem(0);
- v = newaview("records", viewtable_show);
- if(!(v->choice && v->choice->ncols)) {
+ if(!(choice && choice->ncols)) {
ui_set("status", "No table selected.");
return;
}
- selview = v;
+ selview = newaview("records", viewtable_show);
viewtable_show();
}