]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/commitdiff
wtf resolved, was missing LWS_PRE
authorJiří Matěják <jiri.matejak@fel.cvut.cz>
Wed, 16 May 2018 11:35:43 +0000 (13:35 +0200)
committerJiří Matěják <jiri.matejak@fel.cvut.cz>
Wed, 16 May 2018 11:35:43 +0000 (13:35 +0200)
mt_server.c

index 26dc90b2d45d730989ba99805265653367a1f9fa..d6a3904493917afa0155442592aeb31f95b47cf4 100644 (file)
@@ -163,11 +163,12 @@ int mt_server_init(mt_server_t *self, struct ev_loop *loop, int fd)
 
     ev_io_ws *w = &(self->fd_watcher);
     w->context = context;
-    w->text = (char *)malloc(INPUT_LINE_LENGTH*sizeof(char));
+    w->text = (char *)malloc((LWS_PRE + INPUT_LINE_LENGTH)*sizeof(char));
     if (!w->text) {
         perror("malloc");
         return -1;
     }
+    w->text += LWS_PRE;
     strcpy(w->text, JSON_EMPTY);
     w->pos = w->text;
     protocols[PROTOCOL_MERICA_TERMINAL].user = (void *)w->text;
@@ -177,10 +178,10 @@ int mt_server_init(mt_server_t *self, struct ev_loop *loop, int fd)
     return lws_ev_initloop(context, loop, 0);
 }
 
-void mt_server_deinit(mt_server_t *self) //TODO wtf
+void mt_server_deinit(mt_server_t *self)
 {
-    //free(self->fd_watcher.text);
-    //protocols[PROTOCOL_MERICA_TERMINAL].user = NULL;
+    free(self->fd_watcher.text - LWS_PRE);
+    protocols[PROTOCOL_MERICA_TERMINAL].user = NULL;
     lws_context_destroy(self->context);
 }