Commit aaa05e54 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

kdtree: changed unsigned long to size_t.

parent 2536df0f
...@@ -115,7 +115,7 @@ typedef struct kd_thread_data { ...@@ -115,7 +115,7 @@ typedef struct kd_thread_data {
struct kd_point *points; struct kd_point *points;
kdata_t min[KD_MAX_DIM]; kdata_t min[KD_MAX_DIM];
kdata_t max[KD_MAX_DIM]; kdata_t max[KD_MAX_DIM];
unsigned long nPoints; size_t nPoints;
int max_threads; int max_threads;
int depth; int depth;
int dim; int dim;
...@@ -153,18 +153,18 @@ void kd_printTree(struct kdNode *node); ...@@ -153,18 +153,18 @@ void kd_printTree(struct kdNode *node);
/* Functions for building and destroying trees */ /* Functions for building and destroying trees */
void kd_freeNode(kdNode * node); void kd_freeNode(kdNode * node);
struct kdNode *kd_allocNode(struct kd_point *points, unsigned long pivot, struct kdNode *kd_allocNode(struct kd_point *points, size_t pivot,
kdata_t *min, kdata_t *max, int dim, int axis); kdata_t *min, kdata_t *max, int dim, int axis);
void kd_destroyTree(struct kdNode *node); void kd_destroyTree(struct kdNode *node);
struct kd_thread_data *kd_buildArg(struct kd_point *points, struct kd_thread_data *kd_buildArg(struct kd_point *points,
unsigned long nPoints, size_t nPoints,
kdata_t *min, kdata_t *max, kdata_t *min, kdata_t *max,
int depth, int max_threads, int depth, int max_threads,
int dim); int dim);
struct kdNode *kd_buildTree(struct kd_point *points, unsigned long nPoints, struct kdNode *kd_buildTree(struct kd_point *points, size_t nPoints,
kdata_t *min, kdata_t *max, int dim, int max_threads); kdata_t *min, kdata_t *max, int dim, int max_threads);
void *kd_doBuildTree(void *threadarg); void *kd_doBuildTree(void *threadarg);
struct kdNode *kd_sph_buildTree(struct kd_point *points, unsigned long nPoints, struct kdNode *kd_sph_buildTree(struct kd_point *points, size_t nPoints,
kdata_t *min, kdata_t *max, int max_threads); kdata_t *min, kdata_t *max, int max_threads);
void *kd_sph_doBuildTree(void *threadarg); void *kd_sph_doBuildTree(void *threadarg);
......
...@@ -70,14 +70,11 @@ kdata_t kd_min(kdata_t x, kdata_t y) ...@@ -70,14 +70,11 @@ kdata_t kd_min(kdata_t x, kdata_t y)
* \return root node of the tree * \return root node of the tree
*/ */
struct kdNode * struct kdNode *
kd_buildTree(struct kd_point *points, unsigned long nPoints, kd_buildTree(struct kd_point *points, size_t nPoints,
kdata_t *min, kdata_t *max, int dim, int max_threads) kdata_t *min, kdata_t *max, int dim, int max_threads)
{ {
struct kd_thread_data *my_data; struct kd_thread_data *my_data = kd_buildArg(points, nPoints, min, max, 0, max_threads, dim);
struct kdNode *tree; struct kdNode *tree = (kdNode *)kd_doBuildTree(my_data);
my_data = kd_buildArg(points, nPoints, min, max, 0, max_threads, dim);
tree = (kdNode *)kd_doBuildTree(my_data);
free(my_data); free(my_data);
return tree; return tree;
} }
......
...@@ -95,7 +95,7 @@ void *kd_doBuildTree(void *threadarg) ...@@ -95,7 +95,7 @@ void *kd_doBuildTree(void *threadarg)
struct kd_thread_data *my_data = (struct kd_thread_data *) threadarg; struct kd_thread_data *my_data = (struct kd_thread_data *) threadarg;
struct kd_point *points = my_data->points; struct kd_point *points = my_data->points;
unsigned long nPoints = my_data->nPoints; size_t nPoints = my_data->nPoints;
kdata_t *min = my_data->min; kdata_t *min = my_data->min;
kdata_t *max = my_data->max; kdata_t *max = my_data->max;
int depth = my_data->depth; int depth = my_data->depth;
...@@ -120,7 +120,7 @@ void *kd_doBuildTree(void *threadarg) ...@@ -120,7 +120,7 @@ void *kd_doBuildTree(void *threadarg)
*/ */
pmergesort(points, nPoints, sortaxis, max_threads); pmergesort(points, nPoints, sortaxis, max_threads);
unsigned long pivot = nPoints / 2; size_t pivot = nPoints / 2;
if ((node = kd_allocNode(points, pivot, min, max, sortaxis, dim)) == NULL) if ((node = kd_allocNode(points, pivot, min, max, sortaxis, dim)) == NULL)
return NULL; return NULL;
...@@ -192,7 +192,7 @@ kd_freeNode(kdNode *node) ...@@ -192,7 +192,7 @@ kd_freeNode(kdNode *node)
struct kd_thread_data * struct kd_thread_data *
kd_buildArg(struct kd_point *points, kd_buildArg(struct kd_point *points,
unsigned long nPoints, size_t nPoints,
kdata_t *min, kdata_t *max, kdata_t *min, kdata_t *max,
int depth, int max_threads, int dim) int depth, int max_threads, int dim)
{ {
...@@ -219,7 +219,7 @@ struct kdNode *mem_pool = NULL; ...@@ -219,7 +219,7 @@ struct kdNode *mem_pool = NULL;
#endif #endif
struct kdNode * struct kdNode *
kd_allocNode(struct kd_point *points, unsigned long pivot, kd_allocNode(struct kd_point *points, size_t pivot,
kdata_t *min, kdata_t *max, int axis, int dim) kdata_t *min, kdata_t *max, int axis, int dim)
{ {
struct kdNode *node; struct kdNode *node;
......
...@@ -128,14 +128,11 @@ kd_sph_orth_dist(kdata_t *p1, kdata_t *p2, int split) ...@@ -128,14 +128,11 @@ kd_sph_orth_dist(kdata_t *p1, kdata_t *p2, int split)
* \return root node of the tree * \return root node of the tree
*/ */
struct kdNode * struct kdNode *
kd_sph_buildTree(struct kd_point *points, unsigned long nPoints, kd_sph_buildTree(struct kd_point *points, size_t nPoints,
kdata_t *min, kdata_t *max, int max_threads) kdata_t *min, kdata_t *max, int max_threads)
{ {
struct kd_thread_data *my_data; struct kd_thread_data *my_data = kd_buildArg(points, nPoints, min, max, 0,max_threads, 2);
struct kdNode *tree; struct kdNode *tree = (kdNode *)kd_doBuildTree(my_data);
my_data = kd_buildArg(points, nPoints, min, max, 0,max_threads, 2);
tree = (kdNode *)kd_doBuildTree(my_data);
free(my_data); free(my_data);
return tree; return tree;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment