#include "typed_list.h"
#include "mem_arena.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>

list_void *_create_list(Arena *arena, u64 size, u64 count) {
  list_void *list = (list_void *)_alloc_for_list(arena, sizeof(list_void));
  if (!list) {
    return NULL;
  }

  list->items = (void *)_alloc_for_list(arena, size * count);
  if (!list->items) {
    munmap(list, sizeof(list_void));
    return NULL;
  }
  memset(list->items, 0, sizeof(size * count));

  list->capacity = count;
  list->count = 0;

  return list;
}

void *_alloc_for_list(Arena *arena, u64 size) {
  return wapp_mem_arena_alloc(arena, size);
}
