Skip to content

Commit

Permalink
- provide lookup for ringbuffer
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10529 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
lochel committed Nov 16, 2011
1 parent 4e96a46 commit 97349d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion SimulationRuntime/c/math-support/ringbuffer.c
Expand Up @@ -119,12 +119,20 @@ int ringBufferLength(RINGBUFFER *rb)
return rb->nElements;
}

void rotateRingBuffer(RINGBUFFER *rb, int n)
void rotateRingBuffer(RINGBUFFER *rb, int n, void **lookup)
{
long i;

ASSERT(rb->nElements > 0, "empty RingBuffer");
ASSERT3(n < rb->nElements, "index [%d] out of range [%d:%d]", n, 0, rb->nElements-1);
ASSERT3(0 <= n, "index [%d] out of range [%d:%d]", n, 0, rb->nElements-1);
rb->firstElement = (rb->firstElement+n)%rb->bufferSize;

if(lookup)
{
for(i=0; i<rb->nElements; ++i)
lookup[i] = getRingData(rb, i);
}
}

void infoRingBuffer(RINGBUFFER *rb)
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/c/math-support/ringbuffer.h
Expand Up @@ -54,7 +54,7 @@ extern "C" {

int ringBufferLength(RINGBUFFER *rb);

void rotateRingBuffer(RINGBUFFER *rb, int n);
void rotateRingBuffer(RINGBUFFER *rb, int n, void **lookup);

void infoRingBuffer(RINGBUFFER *rb);

Expand Down

0 comments on commit 97349d6

Please sign in to comment.