From a839ff6229f4ae1415dddd5995781acb4bb599e1 Mon Sep 17 00:00:00 2001 From: A404M Date: Tue, 10 Jun 2025 00:39:11 +0330 Subject: fix some return type issues --- code/lib/memory.felan | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'code/lib/memory.felan') diff --git a/code/lib/memory.felan b/code/lib/memory.felan index 2710685..0082a1e 100644 --- a/code/lib/memory.felan +++ b/code/lib/memory.felan @@ -4,9 +4,10 @@ libc :: @c_library("/usr/lib/libc.so.6"); malloc :: @c_function(libc,"malloc",(i64)->(*void)); realloc :: @c_function(libc,"realloc",(*void,i64)->(*void)); free :: @c_function(libc,"free",(*void)->void); +memcpy :: @c_function(libc,"memcpy",(*void,*void,i64)->(*void)); -malloc :: (size:i64,comptime t:type) -> (*t) { - return @cast(malloc(size*@cast(@size_of(t),i64)),*t); +malloc :: (size:u64,comptime t:type) -> (*t) { + return @cast(malloc(@cast(size*@size_of(t),i64)),*t); }; realloc :: (ptr:*anytype,size:u64) -> (@type_of(ptr)) { @@ -22,3 +23,7 @@ realloc :: (ptr:*anytype,size:u64) -> (@type_of(ptr)) { free :: (ptr:*anytype) -> void { free(@cast(ptr,*void)); }; + +memcpy :: (dest:*anytype,src:@type_of(dest),n:u64) -> void { + memcpy(@cast(dest,*void),@cast(src,*void),@cast(n,i64)); +}; -- cgit v1.2.3