leetcode 167. Two Sum II – Input array is sorted

Orignal question can be found here.

My solution is as follows:

int* twoSum(int* numbers, int numbersSize, int target, int* returnSize)
{
        *returnSize=2;
        int i=0;
        int j=numbersSize-1;
        int* result=(int*) malloc(sizeof(int)*(*returnSize));
        while(i<j)
        {
                if(numbers[i]+numbers[j]==target)
                {
                        result[0]=i+1;
                        result[1]=j+1;
                        break;
                }
                else if(numbers[i]+numbers[j]>target)
                        --j;
                else
                        ++i;
        }
        return result;
}