System/Libraries/Graphics2D+Widget: Use CAlloc2()

This commit is contained in:
Alec Murphy 2025-04-21 19:49:25 -04:00
parent 1b5635962f
commit d8fe2f0899
2 changed files with 25 additions and 25 deletions

View file

@ -669,10 +669,10 @@ Context2D* NewContext2D(I64 width, I64 height,
return NULL; return NULL;
break; break;
} }
Context2D* ctx = CAlloc(sizeof(Context2D)); Context2D* ctx = CAlloc2(sizeof(Context2D));
ctx->width = width; ctx->width = width;
ctx->height = height; ctx->height = height;
ctx->fb = CAlloc((width * height) * bpp / 8); ctx->fb = CAlloc2((width * height) * bpp / 8);
ctx->opacity = -1; ctx->opacity = -1;
return @create_callable_context2d(ctx); return @create_callable_context2d(ctx);
} }
@ -1563,7 +1563,7 @@ class @graphics2d
U0 @graphics2d_init() U0 @graphics2d_init()
{ {
Graphics2D.fb = CAlloc(sizeof(Context2D)); Graphics2D.fb = CAlloc2(sizeof(Context2D));
Graphics2D.fb->width = Display.width; Graphics2D.fb->width = Display.width;
Graphics2D.fb->height = Display.height; Graphics2D.fb->height = Display.height;
Graphics2D.fb->fb = Display.fb; 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* @create_callable_context2d(@context2d* ctx)
{ {
@callable_context2d* res = CAlloc(sizeof(@callable_context2d)); @callable_context2d* res = CAlloc2(sizeof(@callable_context2d));
MemCpy(res, ctx, sizeof(@context2d)); MemCpy(res, ctx, sizeof(@context2d));
Free(ctx); Free(ctx);
@ -1674,7 +1674,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y)
// blot // blot
code_size = MSize(&@c2d_blot_wrapper_function); 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); MemCpy(res->blot, &@c2d_blot_wrapper_function, code_size);
a = res->blot; a = res->blot;
@ -1687,7 +1687,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y)
// blur // blur
code_size = MSize(&@c2d_blur_wrapper_function); 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); MemCpy(res->blur, &@c2d_blur_wrapper_function, code_size);
a = res->blur; a = res->blur;
@ -1700,7 +1700,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y)
// copy_rect // copy_rect
code_size = MSize(&@c2d_copy_rect_wrapper_function); 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); MemCpy(res->copy_rect, &@c2d_copy_rect_wrapper_function, code_size);
a = res->copy_rect; a = res->copy_rect;
@ -1713,7 +1713,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y)
// fill // fill
code_size = MSize(&@c2d_fill_wrapper_function); 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); MemCpy(res->fill, &@c2d_fill_wrapper_function, code_size);
a = res->fill; a = res->fill;
@ -1726,7 +1726,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y)
// fill_rect // fill_rect
code_size = MSize(&@c2d_fill_rect_wrapper_function); 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); MemCpy(res->fill_rect, &@c2d_fill_rect_wrapper_function, code_size);
a = res->fill_rect; a = res->fill_rect;
@ -1739,7 +1739,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y)
// peek // peek
code_size = MSize(&@c2d_peek_wrapper_function); 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); MemCpy(res->peek, &@c2d_peek_wrapper_function, code_size);
a = res->peek; a = res->peek;
@ -1752,7 +1752,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y)
// plot // plot
code_size = MSize(&@c2d_plot_wrapper_function); 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); MemCpy(res->plot, &@c2d_plot_wrapper_function, code_size);
a = res->plot; a = res->plot;
@ -1765,7 +1765,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y)
// line // line
code_size = MSize(&@c2d_line_wrapper_function); 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); MemCpy(res->line, &@c2d_line_wrapper_function, code_size);
a = res->line; a = res->line;
@ -1778,7 +1778,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y)
// text // text
code_size = MSize(&@c2d_text_wrapper_function); 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); MemCpy(res->text, &@c2d_text_wrapper_function, code_size);
a = res->text; a = res->text;
@ -1791,7 +1791,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y)
// clipped // clipped
code_size = MSize(&@c2d_clipped_wrapper_function); 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); MemCpy(res->clipped, &@c2d_clipped_wrapper_function, code_size);
a = res->clipped; a = res->clipped;
@ -1804,7 +1804,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y)
// rotated // rotated
code_size = MSize(&@c2d_rotated_wrapper_function); 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); MemCpy(res->rotated, &@c2d_rotated_wrapper_function, code_size);
a = res->rotated; a = res->rotated;
@ -1817,7 +1817,7 @@ U32 @c2d_peek_wrapper_function(I64 x, I64 y)
// scaled // scaled
code_size = MSize(&@c2d_scaled_wrapper_function); 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); MemCpy(res->scaled, &@c2d_scaled_wrapper_function, code_size);
a = res->scaled; a = res->scaled;

View file

@ -333,7 +333,7 @@ U0 @widget_add_widget_to_list(Window* win, Widget* widget)
while (widgets_list->next) { while (widgets_list->next) {
widgets_list = 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->widget = widget;
widget_list_item->prev = widgets_list; widget_list_item->prev = widgets_list;
widgets_list->next = widget_list_item; 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: default:
return NULL; return NULL;
} }
@widget_create_set_values : widget = CAlloc(size_of_widget); @widget_create_set_values : widget = CAlloc2(size_of_widget);
widget->type = type; widget->type = type;
widget->x = x; widget->x = x;
widget->y = y; 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.background = Color(0, 0, 0);
widget(TerminalWidget*)->color.foreground = Color(217, 217, 217); widget(TerminalWidget*)->color.foreground = Color(217, 217, 217);
widget(TerminalWidget*)->color.cursor = Color(217, 217, 0); 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; break;
case WIDGET_TYPE_INPUT: case WIDGET_TYPE_INPUT:
widget(TextInputWidget*)->color = Color(0, 0, 0); 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; break;
case WIDGET_TYPE_LABEL: case WIDGET_TYPE_LABEL:
widget(TextLabelWidget*)->color = Color(0, 0, 0); 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; I32 addr = widget(TextLabelWidget*)->SetText;
MemCpy(addr, widget_self_set1, 0x1F); MemCpy(addr, widget_self_set1, 0x1F);
MemCpy(addr + 12, &widget, 8); MemCpy(addr + 12, &widget, 8);
@ -700,7 +700,7 @@ Widget* @widget_create_widget(Window* win, I64 type, I64 x, I64 y, I64 width,
break; break;
case WIDGET_TYPE_LISTVIEW: case WIDGET_TYPE_LISTVIEW:
widget(ListViewWidget*)->color = Color(0, 0, 0); widget(ListViewWidget*)->color = Color(0, 0, 0);
widget(ListViewWidget*)->items = CAlloc(sizeof(@list_view_item)); widget(ListViewWidget*)->items = CAlloc2(sizeof(@list_view_item));
break; 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.background = Color(0, 0, 0);
widget(TerminalWidget*)->color.foreground = Color(217, 217, 217); widget(TerminalWidget*)->color.foreground = Color(217, 217, 217);
widget(TerminalWidget*)->color.cursor = Color(217, 217, 0); 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; break;
case WIDGET_TYPE_INPUT: case WIDGET_TYPE_INPUT:
widget(TextInputWidget*)->color = Color(0, 0, 0); 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_start = -1;
widget(TextInputWidget*)->selected_region_end = -1; widget(TextInputWidget*)->selected_region_end = -1;
widget(TextInputWidget*)->color = Color(0, 0, 0); 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; addr = widget(TextInputWidget*)->SetFont;
MemCpy(addr, widget_self_set1, 0x1F); MemCpy(addr, widget_self_set1, 0x1F);
MemCpy(addr + 12, &widget, 8); MemCpy(addr + 12, &widget, 8);
@ -803,7 +803,7 @@ U0 @widget_init_widget(Widget* widget, Window* win, I64 type, I64 x, I64 y,
break; break;
case WIDGET_TYPE_LABEL: case WIDGET_TYPE_LABEL:
widget(TextLabelWidget*)->color = Color(0, 0, 0); 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; addr = widget(TextLabelWidget*)->SetFont;
MemCpy(addr, widget_self_set1, 0x1F); MemCpy(addr, widget_self_set1, 0x1F);
MemCpy(addr + 12, &widget, 8); MemCpy(addr + 12, &widget, 8);
@ -815,7 +815,7 @@ U0 @widget_init_widget(Widget* widget, Window* win, I64 type, I64 x, I64 y,
break; break;
case WIDGET_TYPE_LISTVIEW: case WIDGET_TYPE_LISTVIEW:
widget(ListViewWidget*)->color = Color(0, 0, 0); widget(ListViewWidget*)->color = Color(0, 0, 0);
widget(ListViewWidget*)->items = CAlloc(sizeof(@list_view_item)); widget(ListViewWidget*)->items = CAlloc2(sizeof(@list_view_item));
break; break;
} }