Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Belle2018-06-18 03:11:08 -0400
committerJan Belle2018-06-18 03:11:08 -0400
commit3a0767800bb81a9f3f1f84024cfc3fcd5769df3f (patch)
tree7fa06ea4a337ecf4b621f39b103649a4144470c9
parentfce1a44a2f8008dbb3729e09a93ab4ac60655ce8 (diff)
downloadorg.eclipse.etrice-3a0767800bb81a9f3f1f84024cfc3fcd5769df3f.tar.gz
org.eclipse.etrice-3a0767800bb81a9f3f1f84024cfc3fcd5769df3f.tar.xz
org.eclipse.etrice-3a0767800bb81a9f3f1f84024cfc3fcd5769df3f.zip
[runtime.c] Refactor etStaticDeque api
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/container/etStaticDeque.c4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/container/etStaticDeque.h40
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/src/runtime/container/TestEtStaticDeque.c4
3 files changed, 24 insertions, 24 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/container/etStaticDeque.c b/runtime/org.eclipse.etrice.runtime.c/src/common/container/etStaticDeque.c
index 763185dee..7c08cc716 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/container/etStaticDeque.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/container/etStaticDeque.c
@@ -14,11 +14,11 @@
#include <string.h>
-void etStaticDeque_construct(etStaticDeque* const self, void* memory, int size, int objectSize) {
+void etStaticDeque_construct(etStaticDeque* const self, void* memory, int memorySize, int objectSize) {
self->size = 0;
self->first = 0;
self->memory = memory;
- self->maxSize = size;
+ self->maxSize = memorySize / objectSize;
self->objectSize = objectSize;
etStaticDeque_clear(self);
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/container/etStaticDeque.h b/runtime/org.eclipse.etrice.runtime.c/src/common/container/etStaticDeque.h
index 2333bb0dc..4ec186fd9 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/container/etStaticDeque.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/container/etStaticDeque.h
@@ -26,78 +26,78 @@ typedef struct etStaticDeque {
int first; /* index of the first object */
int size; /* current size of the queue */
int maxSize; /* the maximum size of the queue */
- int objectSize; /* the maximum size of the objects contained in this queue */
+ int objectSize; /* the size of the objects contained in this queue in bytes */
} etStaticDeque;
/**
* Constructs the Deque on the given memory with specified size and objectSize.
*
- * \param self the pointer to the StaticDeque
- * \param memory a pointer to the memory for the objects of the StaticDeque
- * \param size the maximum count of objects that fit into the specified memory
- * \param objectSize the size of the objects stored in the StaticDeque
+ * \param self The pointer to the StaticDeque
+ * \param memory A pointer to the memory for the objects of the StaticDeque
+ * \param memorySize The size of the memory in bytes
+ * \param objectSize The size of the objects stored in the StaticDeque in bytes
*/
-void etStaticDeque_construct(etStaticDeque* self, void* memory, int size, int objectSize);
+void etStaticDeque_construct(etStaticDeque* self, void* memory, int memorySize, int objectSize);
/**
* Clears the Deque, removes all objects.
*
- * \param self the pointer to the StaticDeque
+ * \param self The pointer to the StaticDeque
*/
void etStaticDeque_clear(etStaticDeque* self);
/**
* Returns a reference to an arbitrary object at the specified position.
*
- * \param self the pointer to the StaticDeque
- * \param position the position of the object to be returned
- * \return the object at the specified position
+ * \param self The pointer to the StaticDeque
+ * \param position The position of the object to be returned
+ * \return The object at the specified position
*/
void* etStaticDeque_get(const etStaticDeque* self, int position);
/**
* Copies the object and stores it at the front
*
- * \param self the pointer to the StaticDeque
- * \param object the object to push to the front of the queue
+ * \param self The pointer to the StaticDeque
+ * \param object The object to push to the front of the queue
*/
void etStaticDeque_push_front(etStaticDeque* self, void* object);
/**
* Copies the object and stores it at the end
*
- * \param self the pointer to the StaticDeque
- * \param object the object to push to the end of the queue
+ * \param self The pointer to the StaticDeque
+ * \param object The object to push to the end of the queue
*/
void etStaticDeque_push_back(etStaticDeque* self, void* object);
/**
* Removes the first object
*
- * \param self the pointer to the StaticDeque
+ * \param self The pointer to the StaticDeque
*/
void etStaticDeque_pop_front(etStaticDeque* self);
/**
* Removes the last element
*
- * \param self the pointer to the StaticDeque
+ * \param self The pointer to the StaticDeque
*/
void etStaticDeque_pop_back(etStaticDeque* self);
/**
* Returns a reference to the first object
*
- * \param self the pointer to the StaticDeque
- * \return the object at the front of the queue
+ * \param self The pointer to the StaticDeque
+ * \return The object at the front of the queue
*/
void* etStaticDeque_front(const etStaticDeque* self);
/**
* Returns a reference to the last object
*
- * \param self the pointer to the StaticDeque
- * \return the object at the end of the queue
+ * \param self The pointer to the StaticDeque
+ * \return The object at the end of the queue
*/
void* etStaticDeque_back(const etStaticDeque* self);
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/container/TestEtStaticDeque.c b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/container/TestEtStaticDeque.c
index 67d4a5a8f..e795cf5aa 100644
--- a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/container/TestEtStaticDeque.c
+++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/container/TestEtStaticDeque.c
@@ -34,7 +34,7 @@ void TestEtStaticDeque_testConstruct(etInt16 caseId) {
// Test constructor StaticDeque(void)
etStaticDeque deque;
int memory[10];
- etStaticDeque_construct(&deque, memory, 10, sizeof(int));
+ etStaticDeque_construct(&deque, memory, sizeof(memory), sizeof(int));
EXPECT_EQUAL_INT32(caseId, failMsg, 0, deque.size);
EXPECT_TRUE(caseId, failMsg, deque.size == 0);
}
@@ -45,7 +45,7 @@ void TestEtStaticDeque_testPushPop(etInt16 caseId) {
// Test push_back and push_front with 6 objects of type DataClass
etStaticDeque deque;
DataClass memory[6];
- etStaticDeque_construct(&deque, memory, 6, sizeof(DataClass));
+ etStaticDeque_construct(&deque, memory, sizeof(memory), sizeof(DataClass));
DataClass d1 = { 1, 1.5, "Data 1" };
DataClass d2 = { 2, 2.5, "Data 2" };
DataClass d3 = { 3, 3.5, "Data 3" };

Back to the top