return_code swap_int_buffer(int* buffer, int size, int index1, int index2) {
if(index1 <0 || index2<0){
return INVALID_ARGUMENT_NEGATIVE;
} else if(index1 > size || index2 >size){
return INVALID_INDEX_OUT_OF_BOUNDS;
}else{
int *bucket;
int i;
int j;
bucket = (int*)malloc(sizeof(int)*size);
for(i = size - 1, j = 0; i>=0; i--, j++){
*(bucket+j) = *(buffer+i);
}
for(i=0; i<size; i++){
*(buffer+i) = *(bucket+i);
}
return SUCCESS;
}
return NOT_IMPLEMENTED;
}
I dont understand why when I test this code it doesnt work correctly, the tests are provided by my university, the function is meant to reverse an int array. Am I missing something or? Thanks for any help :)