@@ -108,7 +108,7 @@ struct kdtree *kd_create(int k)
108
108
{
109
109
struct kdtree *tree;
110
110
111
- if (!(tree = ( kdtree*) malloc (sizeof *tree))) {
111
+ if (!(tree = static_cast < kdtree*>( malloc (sizeof *tree) ))) {
112
112
return 0 ;
113
113
}
114
114
@@ -165,10 +165,10 @@ static int insert_rec(struct kdnode **nptr, const double *pos, void *data, int d
165
165
struct kdnode *node;
166
166
167
167
if (!*nptr) {
168
- if (!(node = ( kdnode*) malloc (sizeof *node))) {
168
+ if (!(node = static_cast < kdnode*>( malloc (sizeof *node) ))) {
169
169
return -1 ;
170
170
}
171
- if (!(node->pos = ( double *) malloc (dim * sizeof *node->pos ))) {
171
+ if (!(node->pos = static_cast < double *>( malloc (dim * sizeof *node->pos ) ))) {
172
172
free (node);
173
173
return -1 ;
174
174
}
@@ -212,10 +212,10 @@ int kd_insertf(struct kdtree *tree, const float *pos, void *data)
212
212
if (dim > 16 ) {
213
213
#ifndef NO_ALLOCA
214
214
if (dim <= 256 )
215
- bptr = buf = ( double *) alloca (dim * sizeof *bptr);
215
+ bptr = buf = static_cast < double *>( alloca (dim * sizeof *bptr) );
216
216
else
217
217
#endif
218
- if (!(bptr = buf = ( double *) malloc (dim * sizeof *bptr))) {
218
+ if (!(bptr = buf = static_cast < double *>( malloc (dim * sizeof *bptr) ))) {
219
219
return -1 ;
220
220
}
221
221
} else {
@@ -408,10 +408,10 @@ struct kdres *kd_nearest(struct kdtree *kd, const double *pos)
408
408
if (!kd->rect ) return 0 ;
409
409
410
410
/* Allocate result set */
411
- if (!(rset = ( kdres*) malloc (sizeof *rset))) {
411
+ if (!(rset = static_cast < kdres*>( malloc (sizeof *rset) ))) {
412
412
return 0 ;
413
413
}
414
- if (!(rset->rlist = ( res_node*) alloc_resnode ())) {
414
+ if (!(rset->rlist = static_cast < res_node*>( alloc_resnode () ))) {
415
415
free (rset);
416
416
return 0 ;
417
417
}
@@ -461,10 +461,10 @@ struct kdres *kd_nearestf(struct kdtree *tree, const float *pos)
461
461
if (dim > 16 ) {
462
462
#ifndef NO_ALLOCA
463
463
if (dim <= 256 )
464
- bptr = buf = ( double *) alloca (dim * sizeof *bptr);
464
+ bptr = buf = static_cast < double *>( alloca (dim * sizeof *bptr) );
465
465
else
466
466
#endif
467
- if (!(bptr = buf = ( double *) malloc (dim * sizeof *bptr))) {
467
+ if (!(bptr = buf = static_cast < double *>( malloc (dim * sizeof *bptr) ))) {
468
468
return 0 ;
469
469
}
470
470
} else {
@@ -534,10 +534,10 @@ struct kdres *kd_nearest_range(struct kdtree *kd, const double *pos, double rang
534
534
int ret;
535
535
struct kdres *rset;
536
536
537
- if (!(rset = ( kdres*) malloc (sizeof *rset))) {
537
+ if (!(rset = static_cast < kdres*>( malloc (sizeof *rset) ))) {
538
538
return 0 ;
539
539
}
540
- if (!(rset->rlist = ( res_node*) alloc_resnode ())) {
540
+ if (!(rset->rlist = static_cast < res_node*>( alloc_resnode () ))) {
541
541
free (rset);
542
542
return 0 ;
543
543
}
@@ -563,10 +563,10 @@ struct kdres *kd_nearest_rangef(struct kdtree *kd, const float *pos, float range
563
563
if (dim > 16 ) {
564
564
#ifndef NO_ALLOCA
565
565
if (dim <= 256 )
566
- bptr = buf = ( double *) alloca (dim * sizeof *bptr);
566
+ bptr = buf = static_cast < double *>( alloca (dim * sizeof *bptr) );
567
567
else
568
568
#endif
569
- if (!(bptr = buf = ( double *) malloc (dim * sizeof *bptr))) {
569
+ if (!(bptr = buf = static_cast < double *>( malloc (dim * sizeof *bptr) ))) {
570
570
return 0 ;
571
571
}
572
572
} else {
@@ -689,16 +689,16 @@ static struct kdhyperrect* hyperrect_create(int dim, const double *min, const do
689
689
size_t size = dim * sizeof (double );
690
690
struct kdhyperrect * rect = 0 ;
691
691
692
- if (!(rect = ( kdhyperrect*) malloc (sizeof (struct kdhyperrect )))) {
692
+ if (!(rect = static_cast < kdhyperrect*>( malloc (sizeof (struct kdhyperrect ) )))) {
693
693
return 0 ;
694
694
}
695
695
696
696
rect->dim = dim;
697
- if (!(rect->min = ( double *) malloc (size))) {
697
+ if (!(rect->min = static_cast < double *>( malloc (size) ))) {
698
698
free (rect);
699
699
return 0 ;
700
700
}
701
- if (!(rect->max = ( double *) malloc (size))) {
701
+ if (!(rect->max = static_cast < double *>( malloc (size) ))) {
702
702
free (rect->min );
703
703
free (rect);
704
704
return 0 ;
@@ -806,7 +806,7 @@ static int rlist_insert(struct res_node *list, struct kdnode *item, double dist_
806
806
{
807
807
struct res_node *rnode;
808
808
809
- if (!(rnode = ( res_node*) alloc_resnode ())) {
809
+ if (!(rnode = static_cast < res_node*>( alloc_resnode () ))) {
810
810
return -1 ;
811
811
}
812
812
rnode->item = item;
0 commit comments