fix memory alloc in headers