cleaner message stack
@@ -32,15 +32,17 @@ void mngr_set(module_t* module, msg_t* msg) {
}
void mngr_get_msg(int module_index,int msg_index, mngr_t* chunk) {
+ int i;
if ((module_index < 0) | (msg_index < 0)){
return;
}
// get module
chunk->module = module_msg_mngr[module_index];
hal_disable_irq();
- for (int i = module_index; i < module_msg_available; i++) {
+ for (i = module_index; i < module_msg_available; i++) {
module_msg_mngr[i] = module_msg_mngr[i+1];
}
+ module_msg_mngr[i] = 0;
module_msg_available--;
hal_enable_irq();
@@ -50,6 +52,7 @@ void mngr_get_msg(int module_index,int msg_index, mngr_t* chunk) {
for (int i = msg_index; i < chunk->module->message_available; i++) {
chunk->module->msg_stack[i] = chunk->module->msg_stack[i+1];
}
+ chunk->module->msg_stack[i] = 0;
chunk->module->message_available--;
hal_enable_irq();
}
