Use g_string_erase instead of memmove.
authorDaniel Carl <danielcarl@gmx.de>
Fri, 21 Feb 2020 22:30:54 +0000 (23:30 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Fri, 21 Feb 2020 22:30:54 +0000 (23:30 +0100)
The memmove moved queued keys toward the beginning and left clutter and
unwanted stuff at the end which might cause issues in future. So now
g_string_erase is used which strips chars from the beginning of the
string. This is what the memmove() intended but did not make obvious.

src/map.c

index ed5e599..72d364e 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -170,7 +170,7 @@ MapState map_handle_keys(Client *c, const guchar *keys, int keylen, gboolean use
                 c->map.resolved -= 3;
                 c->map.qlen     -= 3;
                 /* move all other queue entries three steps to the left */
-                memmove(c->map.queue->str, c->map.queue->str + 3, c->map.qlen);
+                g_string_erase(c->map.queue, 0, 3);
             } else {
                 /* get first char of queue */
                 qk = c->map.queue->str[0];
@@ -179,7 +179,7 @@ MapState map_handle_keys(Client *c, const guchar *keys, int keylen, gboolean use
                 c->map.qlen--;
 
                 /* move all other queue entries one step to the left */
-                memmove(c->map.queue->str, c->map.queue->str + 1, c->map.qlen);
+                g_string_erase(c->map.queue, 0, 1);
             }
 
             /* remove the no-map flag */