I am using merge sort function and it contains two list using malloc function. In order to increase the performance, I need to replace the two malloc
calls by allocating a single buffer and setting list1
and list2
by pointing into that buffer. This reduces the number of calls to malloc/free to half.
intType* list1 = (intType*)malloc(n1*sizeof(intType));
intType* list2 = (intType*)malloc(n2*sizeof(intType));
where n1 = N /2;
and n2 = N -2;
N
is the number of elements to be sorted.
I tried different methods but no luck with the implementation. Can someone help here please ?