Skip to content

Commit

Permalink
circular buffer with size one correctly handled
Browse files Browse the repository at this point in the history
  • Loading branch information
swhite2401 committed May 22, 2024
1 parent ef82172 commit 59493cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion atintegrators/BeamLoadingCavityPass.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ struct elem


void write_buffer(double *data, double *buffer, int datasize, int buffersize){
memmove(buffer, buffer + datasize, datasize*buffersize*sizeof(double));
if(buffersize>1){
memmove(buffer, buffer + datasize, datasize*buffersize*sizeof(double));
}
memcpy(buffer + datasize*(buffersize-1), data, datasize*sizeof(double));
}

Expand Down
10 changes: 6 additions & 4 deletions atintegrators/atimplib.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ static double getTableWake(double *waketable,double *waketableT,double distance,
};

static void rotate_table_history(long nturns,long nslice,double *turnhistory,double circumference){
memmove(turnhistory, turnhistory + nslice, 4*nslice*nturns*sizeof(double));
double *z = turnhistory+nslice*nturns*2;
int i;
for(i=0; i<nslice*nturns; i++){
z[i] += -circumference;
if(nturns > 1){
memmove(turnhistory, turnhistory + nslice, 4*nslice*nturns*sizeof(double));
double *z = turnhistory+nslice*nturns*2;
for(i=0; i<nslice*nturns; i++){
z[i] += -circumference;
}
}
double *x0 = turnhistory + (nturns-1)*nslice;
double *y0 = turnhistory + (2*nturns-1)*nslice;
Expand Down

0 comments on commit 59493cc

Please sign in to comment.