库实现之分配内存对齐的程序aligned_malloc和aligned_free函数
分配内存管理对齐的程序void *aligned_malloc(int size, int alignment){void *ptr = (void*)malloc(size + alignment);if (ptr){void * aligned =(void *)(((long)ptr + alignment) & (~(alignment-1)));(void **)aligned[-1] = ptr;return aligned;}return NULL;}释放函数aligned_freevoid *aligned_free(void *paligned){free(paligned);}关键是利用分配的内存首地址的前一地址记录内存真正分配的起始地址
补充:综合编程 , 其他综合 ,