'ArenaBase(arena)' -> 'ArenaFirst(arena, type)'

This commit is contained in:
jacob 2025-11-07 17:42:50 -06:00
parent 9ba2cf6613
commit a94e62e023
28 changed files with 71 additions and 72 deletions

View File

@ -158,15 +158,15 @@ void Startup(void)
{
String key = arg->key;
String value = arg->value;
if (EqString(key, Lit("log")))
if (MatchString(key, Lit("log")))
{
logfile_name = value;
}
else if (EqString(key, Lit("settings")))
else if (MatchString(key, Lit("settings")))
{
settings_file_name = value;
}
else if (EqString(key, Lit("connect")))
else if (MatchString(key, Lit("connect")))
{
connect_address = value;
}

View File

@ -58,7 +58,7 @@ AC_Asset *AC_GetAssetCacheSlotLocked(Lock *lock, String key, u64 hash)
if (slot->hash)
{
/* Occupied */
if (hash == slot->hash && EqString(key, slot->key))
if (hash == slot->hash && MatchString(key, slot->key))
{
/* Matched slot */
return slot;

View File

@ -65,7 +65,7 @@ void *PushBytesNoZero(Arena *arena, u64 size, u64 align)
Assert(!arena->readonly);
void *ptr = 0;
u8 *base = ArenaBase(arena);
u8 *base = ArenaFirst(arena, u8);
/* Check to avoid aligning when size = 0 */
if (size > 0)
@ -117,7 +117,7 @@ void CopyArena(Arena *dst, Arena *src)
{
ResetArena(dst);
u64 data_size = src->pos;
u8 *data_src = ArenaBase(src);
u8 *data_src = ArenaFirst(src, u8);
u8 *data_dst = PushBytesNoZero(dst, data_size, 1);
CopyBytes(data_dst, data_src, data_size);
}

View File

@ -43,20 +43,19 @@ Struct(SharedArenaCtx)
////////////////////////////////////////////////////////////
//~ Arena push/pop
#define PushStruct(a, type) ((type *)PushBytes((a), sizeof(type), alignof(type)))
#define PushStructNoZero(a, type) ((type *)PushBytesNoZero((a), sizeof(type), alignof(type)))
#define PushStructs(a, type, n) ((type *)PushBytes((a), (sizeof(type) * (n)), alignof(type)))
#define PushStruct(a, type) PushStructs((a), type, 1)
#define PushStructsNoZero(a, type, n) ((type *)PushBytesNoZero((a), (sizeof(type) * (n)), alignof(type)))
#define PushStructNoZero(a, type) PushStructsNoZero((a), type, 1)
#define PopStruct(a, type, dst) PopBytes((a), sizeof(type), dst)
#define PopStructs(a, type, n, dst) PopBytes((a), sizeof(type) * (n), dst)
#define PopStructs(a, type, dst, n) PopBytes((a), sizeof(type) * (n), dst)
#define PopStruct(a, type, dst) PopStructs((a), type, 1, (dst))
#define PopStructNoCopy(a, type) PopBytesNoCopy((a), sizeof(type))
#define PopStructsNoCopy(a, type, n) PopBytesNoCopy((a), sizeof(type) * (n))
#define PopStructNoCopy(a, type) PopStructsNoCopy((a), type, 1)
/* TOOD: Replace ArenaBase with 'ArenaFirst(type)' for dynamic-array-style uses */
#define ArenaBase(arena) ((u8 *)(arena) + ArenaHeaderSize)
#define ArenaFirst(arena, type) (type *)((u8 *)(arena) + ArenaHeaderSize)
#define ArenaCount(arena, type) ((arena)->pos / sizeof(type))
/* Returns a pointer to where the next push would be (at alignment of type).
@ -77,7 +76,7 @@ Inline void PopTo(Arena *arena, u64 pos)
Assert(arena->pos >= pos);
Assert(!arena->readonly);
AsanPoison(ArenaBase(arena) + pos, arena->pos - pos);
AsanPoison(ArenaFirst(arena, u8) + pos, arena->pos - pos);
arena->pos = pos;
}
@ -86,7 +85,7 @@ Inline void PopBytesNoCopy(Arena *arena, u64 size)
Assert(arena->pos >= size);
Assert(!arena->readonly);
u64 new_pos = arena->pos - size;
AsanPoison(ArenaBase(arena) + new_pos, arena->pos - new_pos);
AsanPoison(ArenaFirst(arena, u8) + new_pos, arena->pos - new_pos);
arena->pos = new_pos;
}
@ -96,10 +95,10 @@ Inline void PopBytes(Arena *arena, u64 size, void *copy_dst)
Assert(!arena->readonly);
u64 new_pos = arena->pos - size;
void *src = (void *)(ArenaBase(arena) + new_pos);
void *src = (void *)(ArenaFirst(arena, u8) + new_pos);
CopyBytes(copy_dst, src, size);
AsanPoison(ArenaBase(arena) + new_pos, arena->pos - new_pos);
AsanPoison(ArenaFirst(arena, u8) + new_pos, arena->pos - new_pos);
arena->pos = new_pos;
}
@ -107,7 +106,7 @@ Inline void *_PushDry(Arena *arena, u64 align)
{
u64 aligned_start_pos = (arena->pos + (align - 1));
aligned_start_pos -= aligned_start_pos % align;
void *ptr = ArenaBase(arena) + aligned_start_pos;
void *ptr = ArenaFirst(arena, u8) + aligned_start_pos;
return ptr;
}
@ -136,21 +135,21 @@ Inline void *PushAlign(Arena *arena, u64 align)
}
else
{
return (void *)(ArenaBase(arena) + arena->pos);
return (void *)(ArenaFirst(arena, u8) + arena->pos);
}
}
else
{
/* 0 alignment */
Assert(0);
return (void *)(ArenaBase(arena) + arena->pos);
return (void *)(ArenaFirst(arena, u8) + arena->pos);
}
}
Inline void *ResetArena(Arena *arena)
{
PopTo(arena, 0);
return (void *)ArenaBase(arena);
return ArenaFirst(arena, u8);
}
////////////////////////////////////////////////////////////

View File

@ -36,7 +36,7 @@ BB_Writer BB_WriterFromBuff(BB_Buff *bb)
result.bb = bb;
if (bb->is_backed_by_arena)
{
result.base = ArenaBase(bb->arena);
result.base = ArenaFirst(bb->arena, u8);
}
else
{
@ -387,7 +387,7 @@ BB_Reader BB_ReaderFromBuff(BB_Buff *bb)
else
{
Arena *arena = bb->arena;
result.base = ArenaBase(arena);
result.base = ArenaFirst(arena, u8);
result.base_len = arena->pos;
}
result.cur_bit = 0;
@ -926,7 +926,7 @@ void BB_Test(void)
{
String w = c.s.v;
String r = BB_ReadString(scratch.arena, &br);
Assert(EqString(r, w));
Assert(MatchString(r, w));
}
else
{

View File

@ -194,7 +194,7 @@ BuddyBlock *GetUnusedBuddyBlock(BuddyCtx *ctx, BuddyLevel *level)
BuddyBlock *left = PushBuddyBlock(ctx);
left->is_used = 1;
left->level = level;
left->memory = ArenaBase(arena);
left->memory = ArenaFirst(arena, u8);
/* Create right LAX block from new arena memory */
BuddyBlock *right = PushBuddyBlock(ctx);

View File

@ -93,7 +93,7 @@ CommandlineArg CommandlineArgFromName(String name)
u64 hash = HashFnv64(Fnv64Basis, name);
for (CommandlineArgNode *n = g->arg_bins[hash % CommandlineArgBinsCount]; n; n = n->next)
{
if (n->hash == hash && EqString(n->arg.name, name))
if (n->hash == hash && MatchString(n->arg.name, name))
{
result = n->arg;
break;

View File

@ -878,7 +878,7 @@ b32 IsVec2Zero(Vec2 a)
return a.x == 0 && a.y == 0;
}
b32 EqVec2(Vec2 a, Vec2 b)
b32 MatchVec2(Vec2 a, Vec2 b)
{
return a.x == b.x && a.y == b.y;
}
@ -1099,7 +1099,7 @@ Vec2 SlerpVec2(Vec2 val0, Vec2 val1, f32 t)
////////////////////////////////////////////////////////////
//~ Vec2I32 Operations
b32 EqVec2I32(Vec2I32 a, Vec2I32 b)
b32 MatchVec2I32(Vec2I32 a, Vec2I32 b)
{
return a.x == b.x && a.y == b.y;
}
@ -1151,9 +1151,9 @@ PackedVec4 PackVec4(Vec4 v)
////////////////////////////////////////////////////////////
//~ Xform operations
b32 EqXform(Xform xf1, Xform xf2)
b32 MatchXform(Xform xf1, Xform xf2)
{
return EqVec2(xf1.og, xf2.og) && EqVec2(xf1.bx, xf2.bx) && EqVec2(xf1.by, xf2.by);
return MatchVec2(xf1.og, xf2.og) && MatchVec2(xf1.bx, xf2.bx) && MatchVec2(xf1.by, xf2.by);
}
//- Initialization

View File

@ -273,7 +273,7 @@ Vec4 BlendSrgb(Vec4 v0, Vec4 v1, f32 t);
#define Vec2FromFields(v) VEC2((v).x, (v).y)
b32 IsVec2Zero(Vec2 a);
b32 EqVec2(Vec2 a, Vec2 b);
b32 MatchVec2(Vec2 a, Vec2 b);
//- Mul
Vec2 MulVec2(Vec2 a, f32 s);
@ -328,7 +328,7 @@ Vec2 SlerpVec2(Vec2 val0, Vec2 val1, f32 t);
////////////////////////////////////////////////////////////
//~ Vec2I32 Operations
b32 EqVec2I32(Vec2I32 a, Vec2I32 b);
b32 MatchVec2I32(Vec2I32 a, Vec2I32 b);
Vec2I32 NegVec2I32(Vec2I32 a);
Vec2I32 AddVec2I32(Vec2I32 a, Vec2I32 b);
Vec2I32 SubVec2I32(Vec2I32 a, Vec2I32 b);
@ -343,7 +343,7 @@ PackedVec4 PackVec4(Vec4 v);
////////////////////////////////////////////////////////////
//~ Xform operations
b32 EqXform(Xform xf1, Xform xf2);
b32 MatchXform(Xform xf1, Xform xf2);
//- Initialization
#define XformIdentity (Xform) { .bx = VEC2(1, 0), .by = VEC2(0, 1) }

View File

@ -17,14 +17,14 @@ void SetMemoryReadWrite(void *address, u64 size);
//~ Memory operations
//- Wrappers
#define ZeroStruct(ptr) ZeroBytes((ptr), sizeof(*(ptr)))
#define ZeroStructs(ptr, n) ZeroBytes((ptr), sizeof(*(ptr)) * (n))
#define ZeroArray(a) Assert(IsArray(a)); ZeroBytes((a), sizeof((a)))
#define CopyStruct(ptr_dst, ptr_src) CopyBytes((ptr_dst), (ptr_src), sizeof(*(ptr_dst)))
#define CopyStructs(ptr_dst, ptr_src, n) CopyBytes((ptr_dst), (ptr_src), sizeof(*(ptr_dst)) * (n))
#define EqStruct(p1, p2) EqBytes((p1), (p2), sizeof(*p1))
#define MatchBytes(p1, p2, n) (CmpBytes((p1), (p2), (n)) == 0)
#define MatchStruct(p1, p2) MatchBytes((p1), (p2), sizeof(*p1))
#define ZeroBytes(ptr, count) SetBytes((ptr), 0, (count))
#define EqBytes(p1, p2, n) (CmpBytes((p1), (p2), (n)) == 0)
#define ZeroArray(a) Assert(IsArray(a)); ZeroBytes((a), sizeof((a)))
#define ZeroStructs(ptr, n) ZeroBytes((ptr), sizeof(*(ptr)) * (n))
#define ZeroStruct(ptr) ZeroStructs((ptr), 1)
#define CopyStructs(ptr_dst, ptr_src, n) CopyBytes((ptr_dst), (ptr_src), sizeof(*(ptr_dst)) * (n))
#define CopyStruct(ptr_dst, ptr_src) CopyStructs((ptr_dst), (ptr_src), 1)
#define CopyBytes(dst, src, count) memcpy(dst, src, count)
#define SetBytes(dst, c, count) memset(dst, c, count)

View File

@ -250,7 +250,7 @@ StringArray SplitString(Arena *arena, String str, String delim)
cmp.text = &str.text[i];
cmp.len = MinI64(str.len - i, delim.len);
b32 is_delimiter = EqString(cmp, delim);
b32 is_delimiter = MatchString(cmp, delim);
if (is_delimiter)
{
String piece = ZI;
@ -336,7 +336,7 @@ String LowerString(Arena *arena, String str)
//- Compare
b32 EqString(String str1, String str2)
b32 MatchString(String str1, String str2)
{
b32 eq = 1;
if (str1.len == str2.len)

View File

@ -76,7 +76,7 @@ String CatString(Arena *arena, String str1, String str2);
StringArray SplitString(Arena *arena, String str, String delim);
String IndentString(Arena *arena, String str, u32 indent);
String LowerString(Arena *arena, String str);
b32 EqString(String str1, String str2);
b32 MatchString(String str1, String str2);
b32 StringContains(String str, String substring);
b32 StringBeginsWith(String str, String substring);
b32 StringEndsWith(String str, String substring);

View File

@ -15,5 +15,5 @@ Struct(Uid)
Uid UidFromTrueRand(void);
Uid CombineUid(Uid a, Uid b);
Inline b32 EqUid(Uid a, Uid b) { return a.hi == b.hi && a.lo == b.lo; }
Inline b32 MatchUid(Uid a, Uid b) { return a.hi == b.hi && a.lo == b.lo; }
Inline b32 IsUidZero(Uid v) { return v.hi == 0 && v.lo == 0; }

View File

@ -275,7 +275,7 @@ i32 W32_Main(void)
if (SUCCEEDED(hr))
{
u64 thread_name_len = WstrLenNoLimit(thread_name_wstr);
if (thread_name_len >= prefix_name_wstr_len && EqBytes(thread_name_wstr, prefix_name_wstr, prefix_name_wstr_len))
if (thread_name_len >= prefix_name_wstr_len && MatchBytes(thread_name_wstr, prefix_name_wstr, prefix_name_wstr_len))
{
__profn("Set profiler thread affinity");
b32 ok = SetThreadAffinityMask(thread, ProfilerThreadAffinityMask) != 0;

View File

@ -996,7 +996,7 @@ Vec2Array CLD_Menkowski(Arena *arena, CLD_Shape *shape0, CLD_Shape *shape1, Xfor
f32 angle = ((f32)i / detail) * (2 * Pi);
Vec2 dir = Vec2FromAngle(angle);
CLD_MenkowskiPoint m = CLD_MenkowskiPointFromDir(shape0, shape1, xf0, xf1, dir);
if (result.count == 0 || !EqVec2(m.p, result.points[result.count - 1]))
if (result.count == 0 || !MatchVec2(m.p, result.points[result.count - 1]))
{
*PushStructNoZero(arena, Vec2) = m.p;
++result.count;

View File

@ -213,7 +213,7 @@ GPU_Resource *GPU_UploadTransientBuffer(GPU_TransientBuffer *tbuff, void *src, u
GPU_Resource *GPU_UploadTransientBufferFromArena(GPU_TransientBuffer *tbuff, Arena *arena)
{
u32 element_count = arena->pos / tbuff->element_size;
GPU_Resource *result = GPU_UploadTransientBuffer(tbuff, ArenaBase(arena), tbuff->element_size * element_count);
GPU_Resource *result = GPU_UploadTransientBuffer(tbuff, ArenaFirst(arena, u8), tbuff->element_size * element_count);
return result;
}

View File

@ -1913,7 +1913,7 @@ GPU_D12_SwapchainBuffer *GPU_D12_UpdateSwapchain(GPU_D12_Swapchain *swapchain, V
GPU_D12_SharedState *g = &GPU_D12_shared_state;
resolution.x = MaxI32(resolution.x, 1);
resolution.y = MaxI32(resolution.y, 1);
b32 should_rebuild = !EqVec2I32(swapchain->resolution, resolution);
b32 should_rebuild = !MatchVec2I32(swapchain->resolution, resolution);
if (should_rebuild)
{
HRESULT hr = 0;

View File

@ -303,7 +303,7 @@ JSON_TokenList JSON_TokensFromString(Arena *arena, String src)
.len = keyword.len,
.text = &src.text[pos]
};
match = EqString(cmp_str, keyword);
match = MatchString(cmp_str, keyword);
}
}

View File

@ -115,7 +115,7 @@ void OS_DirContentsFromFullPath(Arena *arena, StringList *list, String path)
while (found)
{
String file_name = StringFromWstrNoLimit(arena, find_data.cFileName);
if (!EqString(file_name, Lit(".")) && !EqString(file_name, Lit("..")))
if (!MatchString(file_name, Lit(".")) && !MatchString(file_name, Lit("..")))
{
PushStringToList(arena, list, file_name);
}

View File

@ -407,7 +407,7 @@ MIX_PcmF32 MIX_MixAllTracks(Arena *arena, u64 frame_count)
Vec2 pos = desc.pos;
/* If sound pos = listener pos, pretend sound is close in front of listener. */
if (EqVec2(listener_pos, pos))
if (MatchVec2(listener_pos, pos))
{
pos = AddVec2(listener_pos, MulVec2(listener_dir, 0.001f));
}

View File

@ -68,7 +68,7 @@ N_Channel *N_ChannelFromAddress(N_Host *host, P_Address address)
N_ChannelLookupBin *bin = &host->channel_lookup_bins[hash % host->num_channel_lookup_bins];
for (N_Channel *channel = bin->first; channel; channel = channel->next_address_hash)
{
if (channel->address_hash == hash && P_AddressIsEqual(channel->address, address))
if (channel->address_hash == hash && P_MatchAddress(channel->address, address))
{
return channel;
}
@ -93,7 +93,7 @@ N_Channel *N_ChannelFromId(N_Host *host, N_ChannelId channel_id)
N_ChannelList N_ChannelsFromId(Arena *arena, N_Host *host, N_ChannelId channel_id)
{
N_ChannelList result = ZI;
if (N_EqChannelId(channel_id, N_AllChannelsId))
if (N_MatchChannelId(channel_id, N_AllChannelsId))
{
for (u64 i = 0; i < host->num_channels_reserved; ++i)
{
@ -240,7 +240,7 @@ N_MsgAssembler *N_MsgAssemblerFromMsg(N_Host *host, N_ChannelId channel_id, u64
N_MsgAssemblerLookupBin *bin = &host->msg_assembler_lookup_bins[hash % host->num_msg_assembler_lookup_bins];
for (N_MsgAssembler *ma = bin->first; ma; ma = ma->next_hash)
{
if (ma->hash == hash && N_EqChannelId(ma->channel->id, channel_id) && ma->msg_id == msg_id)
if (ma->hash == hash && N_MatchChannelId(ma->channel->id, channel_id) && ma->msg_id == msg_id)
{
return ma;
}

View File

@ -271,7 +271,7 @@ void N_ReleaseHost(N_Host *host);
#define N_NilChannelId (N_ChannelId) { .gen = 0, .idx = 0 }
#define N_AllChannelsId (N_ChannelId) { .gen = U32Max, .idx = U32Max }
#define N_EqChannelId(a, b) ((a).gen == (b).gen && (a).idx == (b).idx)
#define N_MatchChannelId(a, b) ((a).gen == (b).gen && (a).idx == (b).idx)
#define N_IsChannelIdNil(v) ((v).gen == 0 && (v).idx == 0)
u64 N_HashFromAddress(P_Address address);

View File

@ -328,7 +328,7 @@ P_Address P_AddressFromString(String str);
P_Address P_AddressFromIpPortCstr(char *ip_cstr, char *port_cstr);
P_Address P_AddressFromPort(u16 port);
String P_StringFromAddress(Arena *arena, P_Address address);
b32 P_AddressIsEqual(P_Address a, P_Address b);
b32 P_MatchAddress(P_Address a, P_Address b);
////////////////////////////////////////////////////////////
//~ @hookdecl Sock hooks

View File

@ -778,9 +778,9 @@ String P_StringFromAddress(Arena *arena, P_Address address)
return result;
}
b32 P_AddressIsEqual(P_Address a, P_Address b)
b32 P_MatchAddress(P_Address a, P_Address b)
{
return EqStruct(&a, &b);
return MatchStruct(&a, &b);
}
////////////////////////////////////////////////////////////

View File

@ -68,7 +68,7 @@ P_WindowSettings *SETTINGS_WindowSettingsFromString(Arena *arena, String src, St
}
JSON_Blob *window = root->child_first;
if (!window || window->type != JSON_Type_Object || !EqString(window->key, Lit("window")))
if (!window || window->type != JSON_Type_Object || !MatchString(window->key, Lit("window")))
{
error = Lit("\"window\" object not found");
goto abort;
@ -84,7 +84,7 @@ P_WindowSettings *SETTINGS_WindowSettingsFromString(Arena *arena, String src, St
{
String key = child->key;
if (EqString(key, Lit("maximized")))
if (MatchString(key, Lit("maximized")))
{
if (child->type != JSON_Type_Bool)
{
@ -97,7 +97,7 @@ P_WindowSettings *SETTINGS_WindowSettingsFromString(Arena *arena, String src, St
}
found_maximized = 1;
}
else if (EqString(key, Lit("fullscreen")))
else if (MatchString(key, Lit("fullscreen")))
{
if (child->type != JSON_Type_Bool)
{
@ -110,7 +110,7 @@ P_WindowSettings *SETTINGS_WindowSettingsFromString(Arena *arena, String src, St
}
found_fullscreen = 1;
}
else if (EqString(key, Lit("x")))
else if (MatchString(key, Lit("x")))
{
if (child->type != JSON_Type_Number)
{
@ -120,7 +120,7 @@ P_WindowSettings *SETTINGS_WindowSettingsFromString(Arena *arena, String src, St
settings->floating_x = RoundF32ToI32(child->value.number);
found_x = 1;
}
else if (EqString(key, Lit("y")))
else if (MatchString(key, Lit("y")))
{
if (child->type != JSON_Type_Number)
{
@ -130,7 +130,7 @@ P_WindowSettings *SETTINGS_WindowSettingsFromString(Arena *arena, String src, St
settings->floating_y = RoundF32ToI32(child->value.number);
found_y = 1;
}
else if (EqString(key, Lit("width")))
else if (MatchString(key, Lit("width")))
{
if (child->type != JSON_Type_Number)
{
@ -140,7 +140,7 @@ P_WindowSettings *SETTINGS_WindowSettingsFromString(Arena *arena, String src, St
settings->floating_width = RoundF32ToI32(child->value.number);
found_width = 1;
}
else if (EqString(key, Lit("height")))
else if (MatchString(key, Lit("height")))
{
if (child->type != JSON_Type_Number)
{

View File

@ -31,7 +31,7 @@ TAR_Archive TAR_ArchiveFromString(Arena *arena, String data, String prefix)
TAR_Header header = ZI;
BB_ReadBytes(&br, StringFromStruct(&header));
if (!EqString(StringFromArray(header.ustar_indicator), Lit("ustar\0")))
if (!MatchString(StringFromArray(header.ustar_indicator), Lit("ustar\0")))
{
/* Invalid header */
Assert(0);

View File

@ -426,7 +426,7 @@ b32 UI_IsPointInBox(UI_Box *box, Vec2 point)
Vec2 p1 = box->p1;
b32 is_corner = 0;
f32 non_corner_edge_dist = MinF32(MinF32(point.x - p0.x, p1.x - point.x), MinF32(point.y - p0.y, p1.y - point.y));
f32 corner_edge_dist = 0;
f32 corner_edge_dist = non_corner_edge_dist;
if (non_corner_edge_dist >= 0)
{
f32 tl_radius = box->rounding_tl;
@ -675,7 +675,7 @@ i64 UI_EndFrame(UI_Frame frame)
Fence *submit_fence = GPU_FenceFromQueue(gpu_render_queue);
/* Acquire render target */
if (g->render_target && !EqVec2I32(monitor_size, GPU_GetTextureSize2D(g->render_target)))
if (g->render_target && !MatchVec2I32(monitor_size, GPU_GetTextureSize2D(g->render_target)))
{
__profn("Release ui render target");
YieldOnFence(submit_fence, g->gpu_submit_fence_target);

View File

@ -428,7 +428,7 @@ WND_Frame WND_BeginFrame(void)
{
LockTicketMutex(&window->w2u_tm);
{
ControllerEvent *src = (ControllerEvent *)ArenaBase(window->w2u_events_arena);
ControllerEvent *src = ArenaFirst(window->w2u_events_arena, ControllerEvent);
result.controller_events.count = ArenaCount(window->w2u_events_arena, ControllerEvent);
result.controller_events.events = PushStructsNoZero(window->frame_arena, ControllerEvent, result.controller_events.count);
CopyStructs(result.controller_events.events, src, result.controller_events.count);