[pacman-dev] [PATCH 0/2] Minor cleanups to pacsort
Was reading pacsort today and caught two minor mistakes. Pang Yan Han (2): pacsort: correct pointer type in list_new pacsort: correct list freeing src/util/pacsort.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) -- 1.7.6
Signed-off-by: Pang Yan Han <pangyanhan@gmail.com> --- Pointer sizes are the same but this makes intention clearer. src/util/pacsort.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/util/pacsort.c b/src/util/pacsort.c index 109d1a1..48d183b 100644 --- a/src/util/pacsort.c +++ b/src/util/pacsort.c @@ -103,7 +103,7 @@ static struct list_t *list_new(size_t initial_size) return NULL; } - list->list = calloc(initial_size, sizeof(char **)); + list->list = calloc(initial_size, sizeof(char *)); if(!list->list) { free(list); return NULL; -- 1.7.6
On Mon, Aug 22, 2011 at 12:00 AM, Pang Yan Han <pangyanhan@gmail.com> wrote:
Signed-off-by: Pang Yan Han <pangyanhan@gmail.com> --- Pointer sizes are the same but this makes intention clearer. This comment is on point enough to actually make it in the commit message, so I did just that.
src/util/pacsort.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/util/pacsort.c b/src/util/pacsort.c index 109d1a1..48d183b 100644 --- a/src/util/pacsort.c +++ b/src/util/pacsort.c @@ -103,7 +103,7 @@ static struct list_t *list_new(size_t initial_size) return NULL; }
- list->list = calloc(initial_size, sizeof(char **)); + list->list = calloc(initial_size, sizeof(char *)); if(!list->list) { free(list); return NULL; -- 1.7.6
On Mon, Aug 22, 2011 at 08:41:34AM -0500, Dan McGee wrote:
On Mon, Aug 22, 2011 at 12:00 AM, Pang Yan Han <pangyanhan@gmail.com> wrote:
Signed-off-by: Pang Yan Han <pangyanhan@gmail.com> --- Pointer sizes are the same but this makes intention clearer. This comment is on point enough to actually make it in the commit message, so I did just that.
I don't agree with that point though, since the intention really is to allocate for an array of char *, not just a char *. dave
src/util/pacsort.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/util/pacsort.c b/src/util/pacsort.c index 109d1a1..48d183b 100644 --- a/src/util/pacsort.c +++ b/src/util/pacsort.c @@ -103,7 +103,7 @@ static struct list_t *list_new(size_t initial_size) return NULL; }
- list->list = calloc(initial_size, sizeof(char **)); + list->list = calloc(initial_size, sizeof(char *)); if(!list->list) { free(list); return NULL; -- 1.7.6
On Mon, Aug 22, 2011 at 8:52 AM, Dave Reisner <d@falconindy.com> wrote:
On Mon, Aug 22, 2011 at 08:41:34AM -0500, Dan McGee wrote:
On Mon, Aug 22, 2011 at 12:00 AM, Pang Yan Han <pangyanhan@gmail.com> wrote:
Signed-off-by: Pang Yan Han <pangyanhan@gmail.com> --- Pointer sizes are the same but this makes intention clearer. This comment is on point enough to actually make it in the commit message, so I did just that.
I don't agree with that point though, since the intention really is to allocate for an array of char *, not just a char *.
However, you are using calloc, which is a type and a count. char *ptr = calloc(size, sizeof(char)); char **ptrs = calloc(size, sizeof(char *)); Note that the realloc() call in list_grow already used sizeof(char *) rather than the ** variant. -Dan
Signed-off-by: Pang Yan Han <pangyanhan@gmail.com> --- src/util/pacsort.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/util/pacsort.c b/src/util/pacsort.c index 48d183b..caaac1f 100644 --- a/src/util/pacsort.c +++ b/src/util/pacsort.c @@ -158,8 +158,8 @@ static void list_free(struct list_t *list) free(list->list[i]); } free(list->list); - free(list); } + free(list); } static char *explode(struct buffer_t *buffer, struct list_t *list) -- 1.7.6
participants (3)
-
Dan McGee
-
Dave Reisner
-
Pang Yan Han