mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-11-05 13:29:54 -05:00
format code
This commit is contained in:
parent
b3ccf3b8b8
commit
7e66d5390e
8 changed files with 1085 additions and 1174 deletions
|
|
@ -24,8 +24,8 @@ void *xzalloc(size_t size);
|
|||
* struct wlr_box *box = znew(*box);
|
||||
* char *buf = znew_n(char, 80);
|
||||
*/
|
||||
#define znew(expr) ((__typeof__(expr) *)xzalloc(sizeof(expr)))
|
||||
#define znew_n(expr, n) ((__typeof__(expr) *)xzalloc((n) * sizeof(expr)))
|
||||
#define znew(expr) ((__typeof__(expr) *)xzalloc(sizeof(expr)))
|
||||
#define znew_n(expr, n) ((__typeof__(expr) *)xzalloc((n) * sizeof(expr)))
|
||||
|
||||
/*
|
||||
* As defined in FreeBSD.
|
||||
|
|
@ -49,16 +49,20 @@ char *xstrdup(const char *str);
|
|||
* Same as ptr = xstrdup(str) but free
|
||||
* <ptr> before assigning the result.
|
||||
*/
|
||||
#define xstrdup_replace(ptr, str) do { \
|
||||
free(ptr); (ptr) = xstrdup(str); \
|
||||
} while (0)
|
||||
#define xstrdup_replace(ptr, str) \
|
||||
do { \
|
||||
free(ptr); \
|
||||
(ptr) = xstrdup(str); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Frees memory pointed to by <ptr> and sets <ptr> to NULL.
|
||||
* Does nothing if <ptr> is already NULL.
|
||||
*/
|
||||
#define zfree(ptr) do { \
|
||||
free(ptr); (ptr) = NULL; \
|
||||
} while (0)
|
||||
#define zfree(ptr) \
|
||||
do { \
|
||||
free(ptr); \
|
||||
(ptr) = NULL; \
|
||||
} while (0)
|
||||
|
||||
#endif /* LABWC_MEM_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue