KDArray.c
/*
 * Returns a copy of a point array (with copies of each point)
 *
 * @param arr 		the relevant point array
 * @param size		size of the array arr
 * @return NULL if:
 * 		- arr == NULL
 * 		- size < 1
 * 		- Memory Allocation Error
 *
 * Otherwise the copy of the point array.
 */
Returns a copy of a point array (with copies of each point)

@param arr           the relevant point array
@param size          size of the array arr
@return NULL if:
- arr == NULL
- size < 1
- Memory Allocation Error

Otherwise the copy of the point array.
Returns a copy of a point array ( with copies of each point ) @param arr the relevant point array @param size size of the array arr @return NULL if : - arr == NULL - size < 1 - Memory Allocation Error Otherwise the copy of the point array .
SPPoint* copyPointArray(SPPoint* arr, int size) {
	int i;
	declareLogMsg();
	if (!arr || size < 1) {
		InvalidError()
		return NULL;
	}
	SPPoint* ret = (SPPoint*) malloc(sizeof(SPPoint) * size);
	if (!ret) {
		MallocError()
		return NULL;
	}
	for (i = 0; i < size; i++) {
		ret[i] = spPointCopy(arr[i]);
		if (!ret[i]) {
			MallocError()
			for (i--; i >= 0; i--) {
				free(ret[i]);
			}
			free(ret);
			return NULL;
		}
	}
	return ret;
}
SPPoint * copyPointArray ( SPPoint * arr , int size ) { int i ; declareLogMsg ( ) ; if ( ! arr || size < 1 ) { InvalidError ( ) return NULL ; } SPPoint * ret = ( SPPoint * ) malloc ( sizeof ( SPPoint ) * size ) ; if ( ! ret ) { MallocError ( ) return NULL ; } for ( i = 0 ; i < size ; i ++ ) { ret [ i ] = spPointCopy ( arr [ i ] ) ; if ( ! ret [ i ] ) { MallocError ( ) for ( i -- ; i >= 0 ; i -- ) { free ( ret [ i ] ) ; } free ( ret ) ; return NULL ; } } return ret ; }
Returns a copy of a point array (with copies of each point)
Returns a copy of a point array ( with copies of each point )
/* frees in case of inner malloc fail */