aboutsummaryrefslogtreecommitdiff
path: root/lib/array/array_free.c
blob: 0e5560e3b8d87df5dd771fdef9c9067e870949f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
#include <stdint.h>

#include "array.h"
#include "alloc.h"

void
(array_free)(void *vptr, ptrdiff_t elemsz, ptrdiff_t align)
{
	ptrdiff_t pad = -sizeof(_mlib_arr_hdr_t) & (align - 1);
	_mlib_arr_hdr_t *hdr = _mlib_array_hdr(vptr, align);
	delete(hdr->mem, (uint8_t *)hdr, sizeof(*hdr) + pad + hdr->cap*elemsz);
}