shithub: mc

Download patch

ref: b0d94f7837667c2a95596db88df458bdd3388224
parent: 7baf0c3ce683e750beb30b41cdd7fc2060efbe3f
author: Ori Bernstein <[email protected]>
date: Fri Jan 25 15:45:01 EST 2013

Fix ldel.

    We want to use the list itself to index, not junk mem.

--- a/parse/util.c
+++ b/parse/util.c
@@ -140,16 +140,17 @@
     (*len)++;
 }
 
-void ldel(void *l, size_t *len, size_t idx)
+void ldel(void *p, size_t *len, size_t idx)
 {
-    void ***pl;
+    void ***pl, **l;
 
-    assert(l != NULL);
+    assert(p != NULL);
     assert(idx < *len);
-    pl = l;
-    memmove(&pl[idx - 1], &pl[idx], (*len - idx)*sizeof(void*));
+    pl = p;
+    l = *pl;
+    memmove(&l[idx - 1], &l[idx], (*len - idx)*sizeof(void*));
     (*len)--;
-    *pl = xrealloc(*pl, *len * sizeof(void*));
+    *pl = xrealloc(l, *len * sizeof(void*));
 }