Good practice and meamory leaks

    int* difference (int *a, int *b){
        if (*a > *b){
		*a = *a - *b;
    	}else{
    		*a = *b - *a;
    	}
	    return a;
    }

    int main (){
	    int *xp, *yp;
	    int x, y;

	    x = 9;
	    y = 7;

	    xp = &x;
	    yp = &y;

	    xp = sum (xp,yp);
        printf("xp value: %d\n", *xp);

	    return 0;
    }

For some reasons I need my program to do some mathematical operations on mono dimensional arrays. I posted a sample here because I'm concerned regarding the difference function and its returned value.

The both values are pointers but I need to do this because I can't know for sure which of the values is grater. Is my way of doing things a good practice or is there a better way for this issue?


Good practice and meamory leaks
===


    int* difference (int *a, int *b){
        if (*a > *b){
		*a = *a - *b;
    	}else{
    		*a = *b - *a;
    	}
	    return a;
    }

    int main (){
	    int *xp, *yp;
	    int x, y;

	    x = 9;
	    y = 7;

	    xp = &x;
	    yp = &y;

	    xp = sum (xp,yp);
        printf("xp value: %d\n", *xp);

	    return 0;
    }

For some reasons I need my program to do some mathematical operations on mono dimensional arrays. I posted a sample here because I'm concerned regarding the difference function and its returned value.

The both values are pointers but I need to do this because I can't know for sure which of the values is grater. Is my way of doing things a good practice or is there a better way for this issue?

