summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2013-01-25 20:45:01 -0500
committerOri Bernstein <ori@eigenstate.org>2013-01-25 20:45:01 -0500
commitb0d94f7837667c2a95596db88df458bdd3388224 (patch)
treeda9aecd8d5d4a176257379eb754dc0e40d0c4186
parent7baf0c3ce683e750beb30b41cdd7fc2060efbe3f (diff)
downloadmc-b0d94f7837667c2a95596db88df458bdd3388224.tar.gz
Fix ldel.
We want to use the list itself to index, not junk mem.
-rw-r--r--parse/util.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/parse/util.c b/parse/util.c
index 5d859e2..436b014 100644
--- a/parse/util.c
+++ b/parse/util.c
@@ -140,16 +140,17 @@ void linsert(void *p, size_t *len, size_t idx, void *v)
(*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*));
}