Markus Armbruster
b45c03f585
arm: Use g_new() & friends where that makes obvious sense
g_new(T, n) is neater than g_malloc(sizeof(T) * n). It's also safer,
for two reasons. One, it catches multiplication overflowing size_t.
Two, it returns T * rather than void *, which lets the compiler catch
more type errors.
This commit only touches allocations with size arguments of the form
sizeof(T).
Coccinelle semantic patch:
@@
type T;
@@
-g_malloc(sizeof(T))
+g_new(T, 1)
@@
type T;
@@
-g_try_malloc(sizeof(T))
+g_try_new(T, 1)
@@
type T;
@@
-g_malloc0(sizeof(T))
+g_new0(T, 1)
@@
type T;
@@
-g_try_malloc0(sizeof(T))
+g_try_new0(T, 1)
@@
type T;
expression n;
@@
-g_malloc(sizeof(T) * (n))
+g_new(T, n)
@@
type T;
expression n;
@@
-g_try_malloc(sizeof(T) * (n))
+g_try_new(T, n)
@@
type T;
expression n;
@@
-g_malloc0(sizeof(T) * (n))
+g_new0(T, n)
@@
type T;
expression n;
@@
-g_try_malloc0(sizeof(T) * (n))
+g_try_new0(T, n)
@@
type T;
expression p, n;
@@
-g_realloc(p, sizeof(T) * (n))
+g_renew(T, p, n)
@@
type T;
expression p, n;
@@
-g_try_realloc(p, sizeof(T) * (n))
+g_try_renew(T, p, n)
@@
type T;
expression n;
@@
-(T *)g_new(T, n)
+g_new(T, n)
@@
type T;
expression n;
@@
-(T *)g_new0(T, n)
+g_new0(T, n)
@@
type T;
expression p, n;
@@
-(T *)g_renew(T, p, n)
+g_renew(T, p, n)
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1440524394-15640-1-git-send-email-armbru@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-09-07 10:39:27 +01:00
..
2015-07-27 18:11:53 +03:00
2015-07-27 22:44:47 +03:00
2015-06-03 14:21:24 +03:00
2015-09-07 10:39:27 +01:00
2015-04-27 18:24:18 +02:00
2015-07-29 10:02:06 +01:00
2015-04-28 15:36:08 +02:00
2015-09-07 10:39:27 +01:00
2015-07-13 13:35:51 +01:00
2015-08-13 11:26:22 +01:00
2015-04-11 20:03:57 +10:00
2015-09-07 10:39:27 +01:00
2015-09-07 10:39:27 +01:00
2015-09-07 10:39:27 +01:00
2015-05-29 11:28:59 +01:00
2015-08-13 14:08:30 +03:00
2015-08-03 14:27:12 +00:00
2015-09-07 10:39:27 +01:00
2015-08-13 11:26:21 +01:00
2015-02-26 12:42:16 +01:00
2015-07-08 10:09:55 +03:00
2015-06-03 14:21:24 +03:00
2015-06-22 14:43:25 +01:00
2015-07-03 17:47:58 -03:00
2015-07-09 15:20:40 +02:00
2015-06-26 09:08:50 +01:00
2015-09-07 10:39:27 +01:00
2014-09-09 13:41:43 +02:00
2015-09-02 14:51:07 +01:00
2015-07-07 17:44:50 +02:00
2014-11-03 00:59:10 +03:00
2015-08-13 14:08:29 +03:00
2015-06-23 22:58:36 +02:00
2015-08-13 17:47:44 +01:00
2014-10-24 12:19:11 +01:00
2015-08-13 14:08:29 +03:00
2015-09-03 12:17:54 +02:00
2015-08-14 23:40:32 +02:00
2015-09-07 10:39:27 +01:00
2015-06-12 12:02:48 +02:00
2015-08-13 14:08:30 +03:00
2015-06-10 08:00:37 +02:00
2015-06-10 08:00:37 +02:00
2015-09-07 10:39:27 +01:00
2015-09-07 10:39:27 +01:00
2015-06-22 18:20:40 +02:00
2014-11-02 10:04:34 +03:00
2015-06-03 14:21:24 +03:00
2015-07-27 14:12:18 +01:00
2015-07-22 14:56:01 -06:00
2015-08-05 16:56:34 +03:00
2015-07-14 19:10:03 +02:00
2015-06-23 18:25:55 +01:00
2014-10-20 14:02:25 +02:00
2015-03-10 08:15:33 +03:00
2015-08-13 14:08:30 +03:00