Does realloc of memory allocated by C11 aligned_alloc keep the alignment?

前端 未结 1 1479
一向
一向 2021-02-14 05:32

Consider the following (C11) code:

void *ptr = aligned_alloc(4096, 4096);
... // do something with \'ptr\'
ptr = realloc(ptr, 6000);

Since the

1条回答
  •  别那么骄傲
    2021-02-14 05:54

    The alignment is not kept with the pointer. When you call realloc you can only rely on the alignment that realloc guarantees. You'll need to use aligned_alloc to perform any reallocations.

    0 讨论(0)
提交回复
热议问题