From 8bdafe29900349b315bf37da112e1a3f6f680d34 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Thu, 26 Jun 2008 17:18:56 -0400 Subject: - minor cleanups --- src/backend.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/backend.c b/src/backend.c index f57707b..436dad4 100644 --- a/src/backend.c +++ b/src/backend.c @@ -150,17 +150,18 @@ backend_dup_strlist_n(char **strlist, int n) } /* Allocate space for the array of pointers (with NULL terminator) and * then the string data. */ - ret = malloc(((i + 1) * sizeof(char *)) + l); + ret = malloc(((n + 1) * sizeof(char *)) + l); if (ret != NULL) { /* Figure out where the string data will start. */ - s = (char *) &ret[i + 1]; + s = (char *) ret; + s += ((n + 1) * sizeof(char *)); for (i = 0; i < n; i++) { /* Set the address of this string, copy the data * around, and then prepare the address of the next * string. */ ret[i] = s; strcpy(s, strlist[i]); - s += (strlen(s) + 1); + s += (strlen(strlist[i]) + 1); } /* NULL-terminate the array. */ ret[i] = NULL; -- cgit