Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.
My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 7c2e6c7..f910288 100644 static int bf_action_cb(int action, struct gui_synclist* list) { if (action == ACTION_STD_OK) { - splash(HZ/1, "Attempting a 64k allocation"); - int handle = core_alloc("test", 64<<10); - splash(HZ/2, (handle > 0) ? "Success":"Fail"); - /* for some reason simplelist doesn't allow adding items here if - * info.get_name is given, so use normal list api */ - gui_synclist_set_nb_items(list, core_get_num_blocks()); - if (handle > 0) - core_free(handle); + if (gui_synclist_get_sel_pos(list) == 0) + { + splash(HZ/2, "Freeing test handle"); + splash(HZ/2, "New alloc should trigger compact"); + core_test_free(); + } + else + { + splash(HZ/1, "Attempting a 64k allocation"); + int handle = core_alloc("test", 64<<10); + splash(HZ/2, (handle > 0) ? "Success":"Fail"); + /* for some reason simplelist doesn't allow adding items here if + * info.get_name is given, so use normal list api */ + gui_synclist_set_nb_items(list, core_get_num_blocks()); + if (handle > 0) + core_free(handle); + } action = ACTION_REDRAW; } else if (action == ACTION_NONE) diff --git a/firmware/core_alloc.c b/firmware/core_alloc.c index 2250f5c..919ffab 100644 /* not static so it can be discovered by core_get_data() */ struct buflib_context core_ctx; +static int test_alloc; void core_allocator_init(void) { buffer_init(); void core_allocator_init(void) void *start = buffer_get_buffer(&size); buflib_init(&core_ctx, start, size); buffer_release_buffer(size); + + test_alloc = core_alloc("test", 112); +} + +void core_test_free(void) +{ + if (test_alloc > 0) + test_alloc = core_free(test_alloc); } int core_alloc(const char* name, size_t size) diff --git a/firmware/include/core_alloc.h b/firmware/include/core_alloc.h index f5206c9..aebfd7a 100644 int core_get_num_blocks(void); void core_print_block_at(int block_num, char* buf, size_t bufsize); #endif +void core_test_free(void); + static inline void* core_get_data(int handle) { extern struct buflib_context core_ctx; |