Merge pull request #30973 from mrc0mmand/gcc14
Reorder arguments for calloc()-like functions, part #2
This commit is contained in:
@@ -47,7 +47,7 @@ typedef void* (*mfree_func_t)(void *p);
|
||||
|
||||
#define newdup(t, p, n) ((t*) memdup_multiply(p, (n), sizeof(t)))
|
||||
|
||||
#define newdup_suffix0(t, p, n) ((t*) memdup_suffix0_multiply(p, sizeof(t), (n)))
|
||||
#define newdup_suffix0(t, p, n) ((t*) memdup_suffix0_multiply(p, (n), sizeof(t)))
|
||||
|
||||
#define malloc0(n) (calloc(1, (n) ?: 1))
|
||||
|
||||
@@ -137,7 +137,7 @@ _alloc_(2, 3) static inline void *memdup_multiply(const void *p, size_t need, si
|
||||
|
||||
/* Note that we can't decorate this function with _alloc_() since the returned memory area is one byte larger
|
||||
* than the product of its parameters. */
|
||||
static inline void *memdup_suffix0_multiply(const void *p, size_t size, size_t need) {
|
||||
static inline void *memdup_suffix0_multiply(const void *p, size_t need, size_t size) {
|
||||
if (size_multiply_overflow(size, need))
|
||||
return NULL;
|
||||
|
||||
|
||||
+4
-4
@@ -383,10 +383,10 @@ assert_cc(sizeof(dummy_t) == 0);
|
||||
/* Iterate through each variadic arg. All must be the same type as 'entry' or must be implicitly
|
||||
* convertible. The iteration variable 'entry' must already be defined. */
|
||||
#define VA_ARGS_FOREACH(entry, ...) \
|
||||
_VA_ARGS_FOREACH(entry, UNIQ_T(_entries_, UNIQ), UNIQ_T(_current_, UNIQ), ##__VA_ARGS__)
|
||||
#define _VA_ARGS_FOREACH(entry, _entries_, _current_, ...) \
|
||||
for (typeof(entry) _entries_[] = { __VA_ARGS__ }, *_current_ = _entries_; \
|
||||
((long)(_current_ - _entries_) < (long)ELEMENTSOF(_entries_)) && ({ entry = *_current_; true; }); \
|
||||
_VA_ARGS_FOREACH(entry, UNIQ_T(_entries_, UNIQ), UNIQ_T(_current_, UNIQ), UNIQ_T(_va_sentinel_, UNIQ), ##__VA_ARGS__)
|
||||
#define _VA_ARGS_FOREACH(entry, _entries_, _current_, _va_sentinel_, ...) \
|
||||
for (typeof(entry) _va_sentinel_[1] = {}, _entries_[] = { __VA_ARGS__ __VA_OPT__(,) _va_sentinel_[0] }, *_current_ = _entries_; \
|
||||
((long)(_current_ - _entries_) < (long)(ELEMENTSOF(_entries_) - 1)) && ({ entry = *_current_; true; }); \
|
||||
_current_++)
|
||||
|
||||
#include "log.h"
|
||||
|
||||
Reference in New Issue
Block a user