refactor: change the disk io api to accept device instead of port struct
[lunaix-os.git] / lunaix-os / kernel / mm / valloc.c
index 631f39ee6f0ccd8070f8882bce4a40193588c1f3..02384ef662833f5b00012d7526cd0f6cdb352108 100644 (file)
@@ -67,13 +67,26 @@ valloc(unsigned int size)
 }
 
 void*
-vcalloc(unsigned int size)
+vzalloc(unsigned int size)
 {
     void* ptr = __valloc(size, &piles);
     memset(ptr, 0, size);
     return ptr;
 }
 
+void*
+vcalloc(unsigned int size, unsigned int count)
+{
+    unsigned int alloc_size;
+    if (__builtin_umul_overflow(size, count, &alloc_size)) {
+        return 0;
+    }
+
+    void* ptr = __valloc(alloc_size, &piles);
+    memset(ptr, 0, alloc_size);
+    return ptr;
+}
+
 void
 vfree(void* ptr)
 {
@@ -87,7 +100,7 @@ valloc_dma(unsigned int size)
 }
 
 void*
-vcalloc_dma(unsigned int size)
+vzalloc_dma(unsigned int size)
 {
     void* ptr = __valloc(size, &piles_dma);
     memset(ptr, 0, size);