From 1bd0bc538ef090408b2e4f74efa5a76c6c8110e6 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Wed, 9 Aug 2023 08:25:32 +1000 Subject: [PATCH] minor unalloc improvements. unalloc can now free 'const' pointers, and strings. Signed-off-by: NeilBrown --- DOC/TODO.md | 30 ++++++++++++++++++++++++++++++ core-misc.c | 4 ++-- misc.h | 8 +++++++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/DOC/TODO.md b/DOC/TODO.md index 30160e90..a8539548 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -9,6 +9,34 @@ the file. ### Triage +- [ ] call, not caLl in server.py +- [ ] lib-server received unexpected notification Close +- [ ] should pane ->cx,cy be a struct xy?? +- [ ] revalidate_start shouldn't find cursor on line where it is known + not to be +- [ ] call_render_line_to_point() never returns negative - why do we check? +- [ ] should pane_resize() report if any change happened? +- [ ] I think I want a "Workspaces" concept, maybe tabbed set of tile + collections. I would have one of mail and one for each project + that I might be looking in. I have lots of documents, but few + projects so this would be easier to move between. + "grep" and "make" etc don't care which document in a project they + are in. + "nm" already gets me to the email project quickly. Getting back + is not so easy. + Maybe some docs could be marked "project" and so be easy to find? +- [ ] path completion in shell command. If cannot find look for '/' + following punctuation (=) and try there. +- [ ] resolve shift-left vs shift_left distinction. +- [ ] should zoom affect whole window, not just pane? +- [ ] ditch cached-size for images - store in pane data instead. +- [ ] use foreach_attr for parsing image details +- [ ] mergeview command to show diff between "found" and "replacement". +- [ ] mergeview command to include both found and replacement, discard + expected +- [ ] ./edlib -g doesn't work +- [ ] pop up window to show selection as QR code +- [ ] text qrcode (qr --ascii foo) don't look right in xcb display - [X] factor our list-sort code. - [X] when cx-b and default doc name is v.long, shift gets confused - [X] How to run shell command in "44" window?? @@ -92,6 +120,8 @@ Requirements for a v1.0 release Core features ------------- +- [ ] gather memory usage stats per-pane and allow a dump +- [ ] show doc size in doc list - include undo size? - [X] Discard ccache ?? - [ ] Ensure all panes that should use "Free" properly, and find some what to encourage its use. diff --git a/core-misc.c b/core-misc.c index 805a315f..28a2ebe5 100644 --- a/core-misc.c +++ b/core-misc.c @@ -363,12 +363,12 @@ void *safe do_alloc(struct mempool *pool safe, int size, int zero) return ret; } -void do_unalloc(struct mempool *pool safe, void *obj, int size) +void do_unalloc(struct mempool *pool safe, const void *obj, int size) { if (obj) { pool->bytes -= size; pool->allocations -= 1; - free(obj); + free((void*)obj); } } diff --git a/misc.h b/misc.h index 9e8ecf12..848f30d5 100644 --- a/misc.h +++ b/misc.h @@ -124,7 +124,7 @@ struct mempool { #define MEMPOOL_DECL(_name) struct mempool mem ## _name; void *safe do_alloc(struct mempool *pool safe, int size, int zero); -void do_unalloc(struct mempool *pool safe, void *obj, int size); +void do_unalloc(struct mempool *pool safe, const void *obj, int size); #define alloc(var, pool) \ do { var = do_alloc(&mem##pool, sizeof((var)[0]), 1); } while (0) @@ -138,10 +138,16 @@ void do_unalloc(struct mempool *pool safe, void *obj, int size); #define unalloc_buf(var, size, pool) \ do { do_unalloc(&mem##pool, var, size); (var) = NULL; } while(0) +#define unalloc_str(var, pool) \ + unalloc_buf(var, strlen(var)+1, pool) + #define unalloc_safe(var, pool) \ do { do_unalloc(&mem##pool, var, sizeof((var)[0])); (var)=safe_cast NULL; } while (0) #define unalloc_buf_safe(var, size, pool) \ do { do_unalloc(&mem##pool, var, size); (var) = safe_cast NULL; } while(0) +#define unalloc_str_safe(var, pool) \ + unalloc_buf_safe(var, strlen(var)+1, pool) + #endif /* EDLIB_MISC */ -- 2.39.5