Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 4502401

Browse files
fouriauxpramodk
authored andcommitted
enforce c++ rules before migration (#80)
- fix void* cast - rename delete and new C++ keywords use
1 parent a8f331d commit 4502401

File tree

2 files changed

+44
-44
lines changed

2 files changed

+44
-44
lines changed

coreneuron/nrnoc/register_mech.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ int register_mech(const char** m,
214214
#if VECTORIZE
215215
memb_func[type].vectorized = vectorized ? 1 : 0;
216216
memb_func[type].thread_size_ = vectorized ? (vectorized - 1) : 0;
217-
memb_func[type].thread_mem_init_ = (void*)0;
218-
memb_func[type].thread_cleanup_ = (void*)0;
219-
memb_func[type].thread_table_check_ = (void*)0;
217+
memb_func[type].thread_mem_init_ = NULL;
218+
memb_func[type].thread_cleanup_ = NULL;
219+
memb_func[type].thread_table_check_ = NULL;
220220
memb_func[type].is_point = 0;
221-
memb_func[type].setdata_ = (void*)0;
221+
memb_func[type].setdata_ = NULL;
222222
memb_func[type].dparam_semantics = (int*)0;
223223
memb_list[type].nodecount = 0;
224224
memb_list[type]._thread = (ThreadDatum*)0;

coreneuron/scopmath_core/sparse_thread.c

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static void bksub(SparseObj* so, int _iml);
9797
static void prmat(SparseObj* so);
9898
static void initeqn(SparseObj* so, unsigned maxeqn);
9999
static void free_elm(SparseObj* so);
100-
static Elm* getelm(SparseObj* so, unsigned row, unsigned col, Elm* new);
100+
static Elm* getelm(SparseObj* so, unsigned row, unsigned col, Elm* new_elem);
101101
#pragma acc routine seq
102102
double* _nrn_thread_getelm(SparseObj* so, int row, int col, int _iml);
103103
void* nrn_cons_sparseobj(SPFUN, int, Memb_list*, _threadargsproto_);
@@ -113,10 +113,10 @@ static List* newlist();
113113
static void freelist(List* list);
114114
static void linkitem(Item* item, Item* i);
115115
static void insert(SparseObj* so, Item* item);
116-
static void delete (Item* item);
116+
static void delete_item (Item* item);
117117
static void* myemalloc(unsigned n);
118118
static void myfree(void*);
119-
static void check_assert();
119+
static void check_assert(SparseObj* so);
120120
static void re_link(SparseObj* so, unsigned i);
121121
static SparseObj* create_sparseobj();
122122
void _nrn_destroy_sparseobj_thread(SparseObj* so);
@@ -129,7 +129,7 @@ void _nrn_destroy_sparseobj_thread(SparseObj* so);
129129
#endif
130130

131131
static Elm* nrn_pool_alloc(void* arg) {
132-
return emalloc(sizeof(Elm));
132+
return (Elm*) emalloc(sizeof(Elm));
133133
}
134134

135135
/* sparse matrix dynamic allocation:
@@ -362,7 +362,7 @@ The biggest difference is that elements are no longer removed and this
362362
saves much time allocating and freeing during the solve phase
363363
*/
364364

365-
static Elm* getelm(SparseObj* so, unsigned row, unsigned col, Elm* new)
365+
static Elm* getelm(SparseObj* so, unsigned row, unsigned col, Elm* new_elem)
366366
/* return pointer to row col element maintaining order in rows */
367367
{
368368
register Elm *el, *elnext;
@@ -387,16 +387,16 @@ static Elm* getelm(SparseObj* so, unsigned row, unsigned col, Elm* new)
387387
}
388388
}
389389
/* insert below el */
390-
if (!new) {
391-
new = (Elm*)nrn_pool_alloc(so->elmpool);
392-
new->value = (double*)ecalloc(so->_cntml_padded, sizeof(double));
390+
if (!new_elem) {
391+
new_elem = (Elm*)nrn_pool_alloc(so->elmpool);
392+
new_elem->value = (double*)ecalloc(so->_cntml_padded, sizeof(double));
393393
increase_order(so, row);
394394
}
395-
new->r_down = el->r_down;
396-
el->r_down = new;
397-
new->r_up = el;
398-
if (new->r_down) {
399-
new->r_down->r_up = new;
395+
new_elem->r_down = el->r_down;
396+
el->r_down = new_elem;
397+
new_elem->r_up = el;
398+
if (new_elem->r_down) {
399+
new_elem->r_down->r_up = new_elem;
400400
}
401401
/* search leftward from diag[vrow] */
402402
for (el = so->diag[vrow];; el = elnext) {
@@ -408,13 +408,13 @@ static Elm* getelm(SparseObj* so, unsigned row, unsigned col, Elm* new)
408408
}
409409
}
410410
/* insert to left of el */
411-
new->c_left = el->c_left;
412-
el->c_left = new;
413-
new->c_right = el;
414-
if (new->c_left) {
415-
new->c_left->c_right = new;
411+
new_elem->c_left = el->c_left;
412+
el->c_left = new_elem;
413+
new_elem->c_right = el;
414+
if (new_elem->c_left) {
415+
new_elem->c_left->c_right = new_elem;
416416
} else {
417-
so->rowst[vrow] = new;
417+
so->rowst[vrow] = new_elem;
418418
}
419419
} else { /* in the upper triangle */
420420
/* search upward from diag[vcol] */
@@ -429,16 +429,16 @@ static Elm* getelm(SparseObj* so, unsigned row, unsigned col, Elm* new)
429429
}
430430
}
431431
/* insert above el */
432-
if (!new) {
433-
new = (Elm*)nrn_pool_alloc(so->elmpool);
434-
new->value = (double*)ecalloc(so->_cntml_padded, sizeof(double));
432+
if (!new_elem) {
433+
new_elem = (Elm*)nrn_pool_alloc(so->elmpool);
434+
new_elem->value = (double*)ecalloc(so->_cntml_padded, sizeof(double));
435435
increase_order(so, row);
436436
}
437-
new->r_up = el->r_up;
438-
el->r_up = new;
439-
new->r_down = el;
440-
if (new->r_up) {
441-
new->r_up->r_down = new;
437+
new_elem->r_up = el->r_up;
438+
el->r_up = new_elem;
439+
new_elem->r_down = el;
440+
if (new_elem->r_up) {
441+
new_elem->r_up->r_down = new_elem;
442442
}
443443
/* search right from diag[vrow] */
444444
for (el = so->diag[vrow];; el = elnext) {
@@ -450,16 +450,16 @@ static Elm* getelm(SparseObj* so, unsigned row, unsigned col, Elm* new)
450450
}
451451
}
452452
/* insert to right of el */
453-
new->c_right = el->c_right;
454-
el->c_right = new;
455-
new->c_left = el;
456-
if (new->c_right) {
457-
new->c_right->c_left = new;
453+
new_elem->c_right = el->c_right;
454+
el->c_right = new_elem;
455+
new_elem->c_left = el;
456+
if (new_elem->c_right) {
457+
new_elem->c_right->c_left = new_elem;
458458
}
459459
}
460-
new->row = row;
461-
new->col = col;
462-
return new;
460+
new_elem->row = row;
461+
new_elem->col = col;
462+
return new_elem;
463463
}
464464

465465
double* _nrn_thread_getelm(SparseObj* so, int row, int col, int _iml) {
@@ -544,7 +544,7 @@ static void increase_order(SparseObj* so, unsigned row) {
544544
if (!so->do_flag)
545545
return;
546546
order = so->roworder[row];
547-
delete (order);
547+
delete_item (order);
548548
order->norder++;
549549
insert(so, order);
550550
}
@@ -556,7 +556,7 @@ static void reduce_order(SparseObj* so, unsigned row) {
556556
if (!so->do_flag)
557557
return;
558558
order = so->roworder[row];
559-
delete (order);
559+
delete_item (order);
560560
order->norder--;
561561
insert(so, order);
562562
}
@@ -620,7 +620,7 @@ static void get_next_pivot(SparseObj* so, unsigned i) {
620620
printf("\n");
621621
}
622622
#endif
623-
delete (order);
623+
delete_item (order);
624624
}
625625

626626
/* The following routines support the concept of a list.
@@ -686,7 +686,7 @@ static void insert(SparseObj* so, Item* item) {
686686
linkitem(i, item);
687687
}
688688

689-
static void delete (Item* item) {
689+
static void delete_item (Item* item) {
690690
item->next->prev = item->prev;
691691
item->prev->next = item->next;
692692
item->prev = ITEM0;
@@ -805,7 +805,7 @@ static void re_link(SparseObj* so, unsigned i) {
805805
static SparseObj* create_sparseobj() {
806806
SparseObj* so;
807807

808-
so = myemalloc(sizeof(SparseObj));
808+
so = (SparseObj*) myemalloc(sizeof(SparseObj));
809809
nrn_malloc_lock();
810810
nrn_malloc_unlock();
811811
so->rowst = 0;

0 commit comments

Comments
 (0)