@@ -22,4 +22,12 @@ int qapi_enum_parse(const QEnumLookup *lookup, const char *buf,
int parse_qapi_name(const char *name, bool complete);
+/* For any GenericList @list, insert @element at the front. */
+#define QAPI_LIST_ADD(list, element) do { \
+ typeof(list) _tmp = g_malloc(sizeof(*(list))); \
+ _tmp->value = (element); \
+ _tmp->next = (list); \
+ (list) = _tmp; \
+} while (0)
+
#endif
@@ -5211,7 +5211,7 @@ BlockDriverState *bdrv_find_node(const char *node_name)
BlockDeviceInfoList *bdrv_named_nodes_list(bool flat,
Error **errp)
{
- BlockDeviceInfoList *list, *entry;
+ BlockDeviceInfoList *list;
BlockDriverState *bs;
list = NULL;
@@ -5221,22 +5221,12 @@ BlockDeviceInfoList *bdrv_named_nodes_list(bool flat,
qapi_free_BlockDeviceInfoList(list);
return NULL;
}
- entry = g_malloc0(sizeof(*entry));
- entry->value = info;
- entry->next = list;
- list = entry;
+ QAPI_LIST_ADD(list, info);
}
return list;
}
-#define QAPI_LIST_ADD(list, element) do { \
- typeof(list) _tmp = g_malloc(sizeof(*(list))); \
- _tmp->value = (element); \
- _tmp->next = (list); \
- (list) = _tmp; \
-} while (0)
-
typedef struct XDbgBlockGraphConstructor {
XDbgBlockGraph *graph;
GHashTable *graph_nodes;