[pacman-dev] [PATCH] pacsort: safer sizeof types when allocating memory

Julien Ramseier j.ramseier at gmail.com
Sat Jan 30 12:29:15 UTC 2016

> Le 30 janv. 2016 à 10:00, Allan McRae <allan at archlinux.org> a écrit :
> Why is this safer?

Safer is maybe not the most appropriate word.
This simply prevents mistakes by having to write the correct type twice.

Using char* instead of void* is also semantically incorrect:
-	void **new_list = realloc(list->list, newsz * sizeof(char *));
+	void **new_list = realloc(list->list, newsz * sizeof(*new_list));

- Julien

More information about the pacman-dev mailing list