rbtree: Simplify macros

* NODE_FROM_POINTER() can not be NULL

* shuffle NODE_TO_POINTER() code for readability so that the NULL check
  is on the outside and not the cast
This commit is contained in:
Benjamin Otte 2020-03-05 06:53:26 +01:00
parent 9fedcec82e
commit dc86c744bf

View File

@ -61,8 +61,8 @@ struct _GtkRbNode
};
};
#define NODE_FROM_POINTER(ptr) ((GtkRbNode *) ((ptr) ? (((guchar *) (ptr)) - sizeof (GtkRbNode)) : NULL))
#define NODE_TO_POINTER(node) ((gpointer) ((node) ? (((guchar *) (node)) + sizeof (GtkRbNode)) : NULL))
#define NODE_FROM_POINTER(ptr) ((GtkRbNode *) (((guchar *) (ptr)) - sizeof (GtkRbNode)))
#define NODE_TO_POINTER(node) ((node) ? ((gpointer) (((guchar *) (node)) + sizeof (GtkRbNode))) : NULL)
#define NODE_TO_AUG_POINTER(tree, node) ((gpointer) ((node) ? (((guchar *) (node)) + sizeof (GtkRbNode) + (tree)->element_size) : NULL))
static inline gboolean