feat: (ahci) support multiple AHCI controller
[lunaix-os.git] / lunaix-os / kernel / ds / buffer.c
index 0efea6fe054d7b67e3f699f95e74b90417fea722..7b277c8c768f142bc3881b48c617095c80fce69f 100644 (file)
@@ -6,14 +6,13 @@ vbuf_alloc(struct vecbuf* vec, void* buf, size_t size)
 {
     struct vecbuf* vbuf = valloc(sizeof(struct vecbuf));
 
-    *vbuf =
-      (struct vecbuf){ .buf = { .buffer = buf, .size = size }, .acc_sz = 0 };
+    *vbuf = (struct vecbuf){ .buf = { .buffer = buf, .size = size },
+                             .acc_sz = vbuf_size(vec) + size };
 
     if (vec) {
-        vbuf->acc_sz = vbuf_size(vec) + size;
         llist_append(&vec->components, &vbuf->components);
     } else {
-        llist_init_head(&vec->components);
+        llist_init_head(&vbuf->components);
     }
 
     return vbuf;