From: Daniel Carl Date: Fri, 21 Feb 2020 22:30:54 +0000 (+0100) Subject: Use g_string_erase instead of memmove. X-Git-Url: https://git.owens.tech/style.css/style.css/git?a=commitdiff_plain;h=44cbc4c19ccee2d624620af4193338ff4e278a66;p=vimb.git Use g_string_erase instead of memmove. 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. --- diff --git a/src/map.c b/src/map.c index ed5e599..72d364e 100644 --- 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 */