From d8fe2f08999cf8f9f3ca0ebaf33d4df7acc9e269 Mon Sep 17 00:00:00 2001 From: Alec Murphy Date: Mon, 21 Apr 2025 19:49:25 -0400 Subject: [PATCH] System/Libraries/Graphics2D+Widget: Use CAlloc2() --- System/Libraries/Graphics2D.HC | 32 ++++++++++++++++---------------- System/Libraries/Widget.HC | 18 +++++++++--------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/System/Libraries/Graphics2D.HC b/System/Libraries/Graphics2D.HC index 16025f6..1c9c2f8 100644 --- a/System/Libraries/Graphics2D.HC +++ b/System/Libraries/Graphics2D.HC @@ -669,10 +669,10 @@ Context2D* NewContext2D(I64 width, I64 height, return NULL; break; } - Context2D* ctx = CAlloc(sizeof(Context2D)); + Context2D* ctx = CAlloc2(sizeof(Context2D)); ctx->width = width; ctx->height = height; - ctx->fb = CAlloc((width * height) * bpp / 8); + ctx->fb = CAlloc2((width * height) * bpp / 8); ctx->opacity = -1; return @create_callable_context2d(ctx); } @@ -1563,7 +1563,7 @@ class @graphics2d U0 @graphics2d_init() { - Graphics2D.fb = CAlloc(sizeof(Context2D)); + Graphics2D.fb = CAlloc2(sizeof(Context2D)); Graphics2D.fb->width = Display.width; Graphics2D.fb->height = Display.height; Graphics2D.fb->fb = Display.fb; @@ -1665,7 +1665,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y) @callable_context2d* @create_callable_context2d(@context2d* ctx) { - @callable_context2d* res = CAlloc(sizeof(@callable_context2d)); + @callable_context2d* res = CAlloc2(sizeof(@callable_context2d)); MemCpy(res, ctx, sizeof(@context2d)); Free(ctx); @@ -1674,7 +1674,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y) // blot code_size = MSize(&@c2d_blot_wrapper_function); - res->blot = CAlloc(code_size, adam_task->code_heap); + res->blot = CAlloc2(code_size, adam_task->code_heap); MemCpy(res->blot, &@c2d_blot_wrapper_function, code_size); a = res->blot; @@ -1687,7 +1687,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y) // blur code_size = MSize(&@c2d_blur_wrapper_function); - res->blur = CAlloc(code_size, adam_task->code_heap); + res->blur = CAlloc2(code_size, adam_task->code_heap); MemCpy(res->blur, &@c2d_blur_wrapper_function, code_size); a = res->blur; @@ -1700,7 +1700,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y) // copy_rect code_size = MSize(&@c2d_copy_rect_wrapper_function); - res->copy_rect = CAlloc(code_size, adam_task->code_heap); + res->copy_rect = CAlloc2(code_size, adam_task->code_heap); MemCpy(res->copy_rect, &@c2d_copy_rect_wrapper_function, code_size); a = res->copy_rect; @@ -1713,7 +1713,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y) // fill code_size = MSize(&@c2d_fill_wrapper_function); - res->fill = CAlloc(code_size, adam_task->code_heap); + res->fill = CAlloc2(code_size, adam_task->code_heap); MemCpy(res->fill, &@c2d_fill_wrapper_function, code_size); a = res->fill; @@ -1726,7 +1726,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y) // fill_rect code_size = MSize(&@c2d_fill_rect_wrapper_function); - res->fill_rect = CAlloc(code_size, adam_task->code_heap); + res->fill_rect = CAlloc2(code_size, adam_task->code_heap); MemCpy(res->fill_rect, &@c2d_fill_rect_wrapper_function, code_size); a = res->fill_rect; @@ -1739,7 +1739,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y) // peek code_size = MSize(&@c2d_peek_wrapper_function); - res->peek = CAlloc(code_size, adam_task->code_heap); + res->peek = CAlloc2(code_size, adam_task->code_heap); MemCpy(res->peek, &@c2d_peek_wrapper_function, code_size); a = res->peek; @@ -1752,7 +1752,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y) // plot code_size = MSize(&@c2d_plot_wrapper_function); - res->plot = CAlloc(code_size, adam_task->code_heap); + res->plot = CAlloc2(code_size, adam_task->code_heap); MemCpy(res->plot, &@c2d_plot_wrapper_function, code_size); a = res->plot; @@ -1765,7 +1765,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y) // line code_size = MSize(&@c2d_line_wrapper_function); - res->line = CAlloc(code_size, adam_task->code_heap); + res->line = CAlloc2(code_size, adam_task->code_heap); MemCpy(res->line, &@c2d_line_wrapper_function, code_size); a = res->line; @@ -1778,7 +1778,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y) // text code_size = MSize(&@c2d_text_wrapper_function); - res->text = CAlloc(code_size, adam_task->code_heap); + res->text = CAlloc2(code_size, adam_task->code_heap); MemCpy(res->text, &@c2d_text_wrapper_function, code_size); a = res->text; @@ -1791,7 +1791,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y) // clipped code_size = MSize(&@c2d_clipped_wrapper_function); - res->clipped = CAlloc(code_size, adam_task->code_heap); + res->clipped = CAlloc2(code_size, adam_task->code_heap); MemCpy(res->clipped, &@c2d_clipped_wrapper_function, code_size); a = res->clipped; @@ -1804,7 +1804,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y) // rotated code_size = MSize(&@c2d_rotated_wrapper_function); - res->rotated = CAlloc(code_size, adam_task->code_heap); + res->rotated = CAlloc2(code_size, adam_task->code_heap); MemCpy(res->rotated, &@c2d_rotated_wrapper_function, code_size); a = res->rotated; @@ -1817,7 +1817,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y) // scaled code_size = MSize(&@c2d_scaled_wrapper_function); - res->scaled = CAlloc(code_size, adam_task->code_heap); + res->scaled = CAlloc2(code_size, adam_task->code_heap); MemCpy(res->scaled, &@c2d_scaled_wrapper_function, code_size); a = res->scaled; diff --git a/System/Libraries/Widget.HC b/System/Libraries/Widget.HC index 7176904..1c1e44e 100644 --- a/System/Libraries/Widget.HC +++ b/System/Libraries/Widget.HC @@ -333,7 +333,7 @@ U0 @widget_add_widget_to_list(Window* win, Widget* widget) while (widgets_list->next) { widgets_list = widgets_list->next; } - @window_widgets_list* widget_list_item = CAlloc(sizeof(@window_widgets_list)); + @window_widgets_list* widget_list_item = CAlloc2(sizeof(@window_widgets_list)); widget_list_item->widget = widget; widget_list_item->prev = widgets_list; widgets_list->next = widget_list_item; @@ -666,7 +666,7 @@ Widget* @widget_create_widget(Window* win, I64 type, I64 x, I64 y, I64 width, default: return NULL; } - @widget_create_set_values : widget = CAlloc(size_of_widget); + @widget_create_set_values : widget = CAlloc2(size_of_widget); widget->type = type; widget->x = x; widget->y = y; @@ -681,7 +681,7 @@ Widget* @widget_create_widget(Window* win, I64 type, I64 x, I64 y, I64 width, widget(TerminalWidget*)->color.background = Color(0, 0, 0); widget(TerminalWidget*)->color.foreground = Color(217, 217, 217); widget(TerminalWidget*)->color.cursor = Color(217, 217, 0); - widget(TerminalWidget*)->row = CAlloc(sizeof(@terminal_widget_row) * 2000); + widget(TerminalWidget*)->row = CAlloc2(sizeof(@terminal_widget_row) * 2000); break; case WIDGET_TYPE_INPUT: widget(TextInputWidget*)->color = Color(0, 0, 0); @@ -692,7 +692,7 @@ Widget* @widget_create_widget(Window* win, I64 type, I64 x, I64 y, I64 width, break; case WIDGET_TYPE_LABEL: widget(TextLabelWidget*)->color = Color(0, 0, 0); - widget(TextLabelWidget*)->SetText = CAlloc(0x1F, Fs->code_heap); + widget(TextLabelWidget*)->SetText = CAlloc2(0x1F, Fs->code_heap); I32 addr = widget(TextLabelWidget*)->SetText; MemCpy(addr, widget_self_set1, 0x1F); MemCpy(addr + 12, &widget, 8); @@ -700,7 +700,7 @@ Widget* @widget_create_widget(Window* win, I64 type, I64 x, I64 y, I64 width, break; case WIDGET_TYPE_LISTVIEW: widget(ListViewWidget*)->color = Color(0, 0, 0); - widget(ListViewWidget*)->items = CAlloc(sizeof(@list_view_item)); + widget(ListViewWidget*)->items = CAlloc2(sizeof(@list_view_item)); break; } @@ -782,7 +782,7 @@ U0 @widget_init_widget(Widget* widget, Window* win, I64 type, I64 x, I64 y, widget(TerminalWidget*)->color.background = Color(0, 0, 0); widget(TerminalWidget*)->color.foreground = Color(217, 217, 217); widget(TerminalWidget*)->color.cursor = Color(217, 217, 0); - widget(TerminalWidget*)->row = CAlloc(sizeof(@terminal_widget_row) * 2000); + widget(TerminalWidget*)->row = CAlloc2(sizeof(@terminal_widget_row) * 2000); break; case WIDGET_TYPE_INPUT: widget(TextInputWidget*)->color = Color(0, 0, 0); @@ -791,7 +791,7 @@ U0 @widget_init_widget(Widget* widget, Window* win, I64 type, I64 x, I64 y, widget(TextInputWidget*)->selected_region_start = -1; widget(TextInputWidget*)->selected_region_end = -1; widget(TextInputWidget*)->color = Color(0, 0, 0); - widget(TextInputWidget*)->SetText = CAlloc(0x1F, Fs->code_heap); + widget(TextInputWidget*)->SetText = CAlloc2(0x1F, Fs->code_heap); addr = widget(TextInputWidget*)->SetFont; MemCpy(addr, widget_self_set1, 0x1F); MemCpy(addr + 12, &widget, 8); @@ -803,7 +803,7 @@ U0 @widget_init_widget(Widget* widget, Window* win, I64 type, I64 x, I64 y, break; case WIDGET_TYPE_LABEL: widget(TextLabelWidget*)->color = Color(0, 0, 0); - widget(TextLabelWidget*)->SetText = CAlloc(0x1F, Fs->code_heap); + widget(TextLabelWidget*)->SetText = CAlloc2(0x1F, Fs->code_heap); addr = widget(TextLabelWidget*)->SetFont; MemCpy(addr, widget_self_set1, 0x1F); MemCpy(addr + 12, &widget, 8); @@ -815,7 +815,7 @@ U0 @widget_init_widget(Widget* widget, Window* win, I64 type, I64 x, I64 y, break; case WIDGET_TYPE_LISTVIEW: widget(ListViewWidget*)->color = Color(0, 0, 0); - widget(ListViewWidget*)->items = CAlloc(sizeof(@list_view_item)); + widget(ListViewWidget*)->items = CAlloc2(sizeof(@list_view_item)); break; }