Skip to content

Commit

Permalink
do not take addresses of RANGE variables
Browse files Browse the repository at this point in the history
  • Loading branch information
olupton committed Dec 16, 2022
1 parent b087e99 commit 4c5b008
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 24 deletions.
2 changes: 1 addition & 1 deletion net.hoc
Expand Up @@ -54,7 +54,7 @@ lam[0].ampalist(tmplist)
connmap(mat,inplist,tmplist)
lam[0].gabalist(tmplist)
for lvtr(XO,&x,tmplist,inhv) {
XO.setlink(ininhp.link)
XO.setlink(ininhp.link, ininhp.nsyn, ininhp.maxsyn)
XO.gmax(-1,-x)
}

2 changes: 0 additions & 2 deletions presyn.inc
Expand Up @@ -21,8 +21,6 @@ CONSTRUCTOR {
/* link allows postsyn cell to manipulate presyn list */
link = (double)((unsigned long)hoc_Ecalloc(1, sizeof(PreL))); hoc_malchk();
PRECAST->link2 = link; /* this can be queried to protect against error */
PRECAST->nnpre = &nsyn;
PRECAST->mxpre = &maxsyn;
nsyn = 0.;
maxsyn = 0.;
if (ifarg(2)) {
Expand Down
2 changes: 1 addition & 1 deletion proc.hoc
Expand Up @@ -91,7 +91,7 @@ proc connmap () { local ii,jj,isz,osz,num
if (num<0) {
printf("CONNMAP ERROR: gmax must not be <0.: %d %d %g.\n",ii,jj,num)
return }
XO.setlink(YO.link)
XO.setlink(YO.link, YO.nsyn, YO.maxsyn)
XO.gmax(-1,num)
}
jj=jj+1
Expand Down
25 changes: 8 additions & 17 deletions snsarr.inc
Expand Up @@ -114,23 +114,20 @@ PROCEDURE init_arrays(num) {
}

VERBATIM
static void hshake(SynS* ss, PreL* pl, int flag);
static void hshake(SynS* ss, PreL* pl, int flag, double* p_nsyn, double* p_maxsyn);
ENDVERBATIM
: 2 arguments - index, presyn link
: 3 arguments - presyn link, presyn nsyn, presyn maxsyn
PROCEDURE setlink() {
VERBATIM {
int ii, x, is_new;
SynS *sns;
double ptemp;
PreL *ppsyn;

if (ifarg(2)) {
x = (int)*getarg(1);
ptemp = *getarg(2); /* pick up pointer */
} else {
x = nsyn;
ptemp = *getarg(1);
}
x = nsyn;
ptemp = *getarg(1);
double* p_nsyn = getarg(2);
double* p_maxsyn = getarg(3);

if (x >= maxsyn) {
init_arrays(maxsyn+POSTINC); /* #DEFINE POSTINC 5 */
Expand All @@ -156,7 +153,7 @@ VERBATIM {
is_new = 0;
}

hshake(sns,ppsyn,is_new);
hshake(sns, ppsyn, is_new, p_nsyn, p_maxsyn);

x *= (int)CHAINLEN;
for (ii=x;ii < x + CHAINLEN;ii++) {
Expand All @@ -179,16 +176,10 @@ ENDVERBATIM

: manipulate the presynaptic list remotely
VERBATIM
static void hshake(SynS* ss, PreL* pl, int flag) {
static void hshake(SynS* ss, PreL* pl, int flag, double* nn, double* mx) {
/* ls will be a pointer to presyn cell's array of pointers */
/* flag == 1 if this is a brand new entry */
int ii;
double *nn;
double *mx;

nn = pl->nnpre; /* pointer to presyn npre */
mx = pl->mxpre; /* pointer to presyn maxpre */

/* erase presyn pointer if this has been set before */
if (flag == 0) { /* an old entry */
/* fall out of loop if a pointer exists already */
Expand Down
2 changes: 1 addition & 1 deletion snscode.hoc
Expand Up @@ -338,7 +338,7 @@ begintemplate POSTSYN
}
for k=0,mech_num-1 {
// post, pre, listcnt, syncnt, mechcnt, precnt
mech[k].setlink($o1.object(rannum).link)
mech[k].setlink($o1.object(rannum).link, $o1.object(rannum).nsyn, $o1.object(rannum).maxsyn)
if (setall) {
mech[k].delay(-1,delay) // set most recent (index nsyn-1)
mech[k].gmax(-1,gmax)
Expand Down
2 changes: 0 additions & 2 deletions snshead.inc
Expand Up @@ -51,8 +51,6 @@ typedef struct SynS { /* postsynaptic structure */
typedef struct PreL {
int cpre; /* user code for info about presyn cell */
struct SynS **plst; /* will point to post for postsyn nrn*/
double *nnpre; /* number of pointers currently there */
double *mxpre; /* number permitted before realloc required */
double link2; /* a copy of the link information to confirm correct hook up */
} PreL;

Expand Down

0 comments on commit 4c5b008

Please sign in to comment.