From: Michael D. Lowis Date: Tue, 8 Jan 2019 02:04:38 +0000 (-0500) Subject: fixed some memory leaks X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=6585b94034d377e5275789b73f6ec6718ba4d120;p=projs%2Ftide.git fixed some memory leaks --- diff --git a/config.mk b/config.mk index 4b9626d..1d0680a 100644 --- a/config.mk +++ b/config.mk @@ -31,30 +31,18 @@ LDFLAGS = $(LIBS) -lX11 -lXft -lfontconfig -lXinerama -lutil -lm AR = ar ARFLAGS = rcs -# Enable Sanitizers +# Clang - Enable Sanitizers #CFLAGS += -g -fsanitize=address,undefined #LDFLAGS += -g -fsanitize=address,undefined -# Set the variables below or set them on the command line to enable the -# corresponding feature -DEBUG = 0 -GPROF = 0 -GCOV = 0 - -# GCC Debugging -ifeq ($(DEBUG), 1) - CFLAGS += -g -O0 - LDFLAGS += -g -O0 -endif - -# GCC Profiling -ifeq ($(GPROF), 1) - CFLAGS += -pg - LDFLAGS += -pg -endif - -# GCC Coverage -ifeq ($(GCOV), 1) - CFLAGS += --coverage - LDFLAGS += --coverage -endif +# GCC - Enable Sanitizers +#CFLAGS += -g -fsanitize=address,leak,undefined +#LDFLAGS += -g -fsanitize=address,leak,undefined -lasan + +# GCC/Clang Profiling +#CFLAGS += -pg +#LDFLAGS += -pg + +# GCC/Clang Coverage +#CFLAGS += -g O0 --coverage +#LDFLAGS += -g O0 --coverage diff --git a/src/lib/x11_gc.c b/src/lib/x11_gc.c index b0c6897..2d59a22 100644 --- a/src/lib/x11_gc.c +++ b/src/lib/x11_gc.c @@ -49,6 +49,7 @@ void x11_centerwin(XConf* x) { break; } } + if (p_screens) XFree(p_screens); } void x11_show(XConf* x) { diff --git a/src/tide.c b/src/tide.c index f5ab85a..e130204 100644 --- a/src/tide.c +++ b/src/tide.c @@ -150,9 +150,8 @@ static void mouse_right(WinRegion id, bool pressed, size_t row, size_t col) { SearchTerm = view_fetch(win_view(id), row, col, risfile); view_findstr(win_view(EDIT), SearchDir, SearchTerm); SyncMouse = true; - } else { - free(FetchCmd[1]); } + free(FetchCmd[1]); } } @@ -246,7 +245,8 @@ static void xupdate(Job* job) { int nevents, nqueued; do { nqueued = XEventsQueued(X.display, QueuedAfterFlush); - XGetMotionEvents(X.display, X.self, CurrentTime, CurrentTime, &nevents); + XTimeCoord* coords = XGetMotionEvents(X.display, X.self, CurrentTime, CurrentTime, &nevents); + if (coords) XFree(coords); for (XEvent e; XPending(X.display);) { XNextEvent(X.display, &e); if (!XFilterEvent(&e, None) && X.eventfns[e.type]) @@ -895,11 +895,12 @@ int main(int argc, char** argv) { /* if we still have args left we're going to open it in this instance */ if (*argv) { char* path = realpath(*argv, NULL); - if (!path) path = *argv; /* if file doesnt exist, use the original name */ + if (!path) path = strdup(*argv); /* if file doesnt exist, use the original name */ view_init(win_view(EDIT), path); view_setln(win_view(EDIT), line_num); win_title(path); win_prop_set("FILE", "file", path); + free(path); } /* now create the window and start the event loop */