[pacman-dev] [PATCH 1/2] pacsort: correct pointer type in list_new

Dan McGee dpmcgee at gmail.com
Mon Aug 22 09:56:53 EDT 2011


On Mon, Aug 22, 2011 at 8:52 AM, Dave Reisner <d at 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 at gmail.com> wrote:
>> > Signed-off-by: Pang Yan Han <pangyanhan at 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


More information about the pacman-dev mailing list