Commit b2ade151 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

keep memory of the last string in the queue

parent 75c4c3e1
......@@ -270,6 +270,26 @@ static JSValue readDroneDataStr(JSContext *ctx, StrQueue *pQueue)
JSValue res;
struct strNode *current;
current = pQueue->head;
if (current != NULL) {
res = JS_NewString(ctx, current->str);
if (current->next != NULL) {
pQueue->head = current->next;
delete_str_node(current);
} else {
pQueue->tail = NULL;
}
} else {
res = JS_NewString(ctx, "");
}
return res;
}
static JSValue readDroneDataStrOnce(JSContext *ctx, StrQueue *pQueue)
{
JSValue res;
struct strNode *current;
current = pQueue->head;
if (current != NULL) {
res = JS_NewString(ctx, current->str);
......@@ -306,7 +326,7 @@ static JSValue js_drone_get(JSContext *ctx, JSValueConst thisVal, int magic)
case 8:
return readDroneDataStr(ctx, &(s->receiveMessageQueue));
case 9:
return readDroneDataStr(ctx, &(s->receiveLogQueue));
return readDroneDataStrOnce(ctx, &(s->receiveLogQueue));
case 10:
return JS_NewInt64(ctx, s->timestamp);
default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment