Skip to content

Commit e0eba8c

Browse files
committed
Chore: run clang-format
```bash find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) ! -path "src/3rdparty/*" -print0 | xargs -0 clang-format -i ```
1 parent cdd4cee commit e0eba8c

690 files changed

Lines changed: 28150 additions & 30119 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/common/FFPlatform.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33
#include "common/FFstrbuf.h"
44
#include "common/FFlist.h"
55

6-
typedef struct FFPlatformSysinfo
7-
{
6+
typedef struct FFPlatformSysinfo {
87
FFstrbuf name;
98
FFstrbuf release;
109
FFstrbuf version;
1110
FFstrbuf architecture;
1211
uint32_t pageSize;
1312
} FFPlatformSysinfo;
1413

15-
typedef struct FFPlatform
16-
{
14+
typedef struct FFPlatform {
1715
FFstrbuf homeDir; // Trailing slash included
1816
FFstrbuf cacheDir; // Trailing slash included
1917
FFlist configDirs; // List of FFstrbuf, trailing slash included
@@ -22,11 +20,11 @@ typedef struct FFPlatform
2220
FFstrbuf cwd; // Trailing slash included
2321

2422
uint32_t pid;
25-
#ifndef _WIN32
23+
#ifndef _WIN32
2624
uint32_t uid;
27-
#else
25+
#else
2826
FFstrbuf sid;
29-
#endif
27+
#endif
3028
FFstrbuf userName;
3129
FFstrbuf fullUserName;
3230
FFstrbuf hostName;

src/common/FFcheckmacros.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
#pragma once
22

33
#ifdef _MSC_VER
4-
#include <sal.h>
4+
# include <sal.h>
55
#endif
66

77
#if defined(__has_attribute) && __has_attribute(__warn_unused_result__)
8-
#define FF_C_NODISCARD __attribute__((__warn_unused_result__))
8+
# define FF_C_NODISCARD __attribute__((__warn_unused_result__))
99
#elif defined(_MSC_VER)
10-
#define FF_C_NODISCARD _Check_return_
10+
# define FF_C_NODISCARD _Check_return_
1111
#else
12-
#define FF_C_NODISCARD
12+
# define FF_C_NODISCARD
1313
#endif
1414

1515
#if defined(__has_attribute) && __has_attribute(__format__)
16-
#define FF_C_PRINTF(formatStrIndex, argsStartIndex) __attribute__((__format__ (printf, formatStrIndex, argsStartIndex)))
16+
# define FF_C_PRINTF(formatStrIndex, argsStartIndex) __attribute__((__format__(printf, formatStrIndex, argsStartIndex)))
1717
#else
18-
#define FF_C_PRINTF(formatStrIndex, argsStartIndex)
18+
# define FF_C_PRINTF(formatStrIndex, argsStartIndex)
1919
#endif
2020

2121
#if defined(__has_attribute) && __has_attribute(__format__)
22-
#define FF_C_SCANF(formatStrIndex, argsStartIndex) __attribute__((__format__ (scanf, formatStrIndex, argsStartIndex)))
22+
# define FF_C_SCANF(formatStrIndex, argsStartIndex) __attribute__((__format__(scanf, formatStrIndex, argsStartIndex)))
2323
#else
24-
#define FF_C_SCANF(formatStrIndex, argsStartIndex)
24+
# define FF_C_SCANF(formatStrIndex, argsStartIndex)
2525
#endif
2626

2727
#if defined(__has_attribute) && __has_attribute(__nonnull__)
28-
#define FF_C_NONNULL(argIndex, ...) __attribute__((__nonnull__(argIndex, ##__VA_ARGS__)))
28+
# define FF_C_NONNULL(argIndex, ...) __attribute__((__nonnull__(argIndex, ##__VA_ARGS__)))
2929
#else
30-
#define FF_C_NONNULL(argIndex, ...)
30+
# define FF_C_NONNULL(argIndex, ...)
3131
#endif
3232

3333
#if defined(__has_attribute) && __has_attribute(__returns_nonnull__)
34-
#define FF_C_RETURNS_NONNULL __attribute__((__returns_nonnull__))
34+
# define FF_C_RETURNS_NONNULL __attribute__((__returns_nonnull__))
3535
#else
36-
#define FF_C_RETURNS_NONNULL
36+
# define FF_C_RETURNS_NONNULL
3737
#endif

src/common/FFlist.h

Lines changed: 38 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
#define FF_LIST_DEFAULT_ALLOC 16
1111

12-
typedef struct FFlist
13-
{
12+
typedef struct FFlist {
1413
uint8_t* data;
1514
uint32_t elementSize;
1615
uint32_t length;
@@ -24,121 +23,110 @@ bool ffListShift(FFlist* list, void* result);
2423
// Removes the last element, and copy its value to `*result`
2524
bool ffListPop(FFlist* list, void* result);
2625

27-
static inline void ffListInit(FFlist* list, uint32_t elementSize)
28-
{
26+
static inline void ffListInit(FFlist* list, uint32_t elementSize) {
2927
assert(elementSize > 0);
3028
list->elementSize = elementSize;
3129
list->capacity = 0;
3230
list->length = 0;
3331
list->data = NULL;
3432
}
3533

36-
static inline void ffListInitA(FFlist* list, uint32_t elementSize, uint32_t capacity)
37-
{
34+
static inline void ffListInitA(FFlist* list, uint32_t elementSize, uint32_t capacity) {
3835
ffListInit(list, elementSize);
3936
list->capacity = capacity;
40-
list->data = __builtin_expect(capacity == 0, 0) ? NULL : (uint8_t*) malloc((size_t)list->capacity * list->elementSize);
37+
list->data = __builtin_expect(capacity == 0, 0) ? NULL : (uint8_t*) malloc((size_t) list->capacity * list->elementSize);
4138
}
4239

43-
static inline FFlist ffListCreate(uint32_t elementSize)
44-
{
40+
static inline FFlist ffListCreate(uint32_t elementSize) {
4541
FFlist result;
4642
ffListInit(&result, elementSize);
4743
return result;
4844
}
4945

50-
static inline void* ffListGet(const FFlist* list, uint32_t index)
51-
{
46+
static inline void* ffListGet(const FFlist* list, uint32_t index) {
5247
assert(list->capacity > index);
5348
return list->data + (index * list->elementSize);
5449
}
5550

56-
FF_C_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, void* compElement, bool(*compFunc)(const void*, const void*))
57-
{
58-
for(uint32_t i = 0; i < list->length; i++)
59-
{
60-
if(compFunc(ffListGet(list, i), compElement))
51+
FF_C_NODISCARD static inline uint32_t ffListFirstIndexComp(const FFlist* list, void* compElement, bool (*compFunc)(const void*, const void*)) {
52+
for (uint32_t i = 0; i < list->length; i++) {
53+
if (compFunc(ffListGet(list, i), compElement)) {
6154
return i;
55+
}
6256
}
6357

6458
return list->length;
6559
}
6660

67-
static inline bool ffListContains(const FFlist* list, void* compElement, bool(*compFunc)(const void*, const void*))
68-
{
61+
static inline bool ffListContains(const FFlist* list, void* compElement, bool (*compFunc)(const void*, const void*)) {
6962
return ffListFirstIndexComp(list, compElement, compFunc) != list->length;
7063
}
7164

72-
static inline void ffListSort(FFlist* list, int(*compar)(const void*, const void*))
73-
{
65+
static inline void ffListSort(FFlist* list, int (*compar)(const void*, const void*)) {
7466
qsort(list->data, list->length, list->elementSize, compar);
7567
}
7668

7769
// Move the contents of `src` into `list`, and left `src` empty
78-
static inline void ffListInitMove(FFlist* list, FFlist* src)
79-
{
80-
if (src)
81-
{
70+
static inline void ffListInitMove(FFlist* list, FFlist* src) {
71+
if (src) {
8272
list->elementSize = src->elementSize;
8373
list->capacity = src->capacity;
8474
list->length = src->length;
8575
list->data = src->data;
8676
ffListInit(src, list->elementSize);
87-
}
88-
else
89-
{
77+
} else {
9078
ffListInit(list, 0);
9179
}
9280
}
9381

94-
static inline void ffListDestroy(FFlist* list)
95-
{
96-
if (!list->data) return;
82+
static inline void ffListDestroy(FFlist* list) {
83+
if (!list->data) {
84+
return;
85+
}
9786

98-
//Avoid free-after-use. These 3 assignments are cheap so don't remove them
87+
// Avoid free-after-use. These 3 assignments are cheap so don't remove them
9988
list->capacity = list->length = 0;
10089
free(list->data);
10190
list->data = NULL;
10291
}
10392

104-
static inline void ffListClear(FFlist* list)
105-
{
93+
static inline void ffListClear(FFlist* list) {
10694
list->length = 0;
10795
}
10896

109-
static inline void ffListReserve(FFlist* list, uint32_t newCapacity)
110-
{
111-
if (__builtin_expect(newCapacity <= list->capacity, false))
97+
static inline void ffListReserve(FFlist* list, uint32_t newCapacity) {
98+
if (__builtin_expect(newCapacity <= list->capacity, false)) {
11299
return;
100+
}
113101

114102
list->data = (uint8_t*) realloc(list->data, (size_t) newCapacity * list->elementSize);
115103
list->capacity = newCapacity;
116104
}
117105

118-
#define FF_LIST_FOR_EACH(itemType, itemVarName, listVar) \
119-
assert(sizeof(itemType) == (listVar).elementSize); \
120-
for(itemType* itemVarName = (itemType*)(listVar).data; \
121-
itemVarName - (itemType*)(listVar).data < (intptr_t)(listVar).length; \
106+
#define FF_LIST_FOR_EACH(itemType, itemVarName, listVar) \
107+
assert(sizeof(itemType) == (listVar).elementSize); \
108+
for (itemType* itemVarName = (itemType*) (listVar).data; \
109+
itemVarName - (itemType*) (listVar).data < (intptr_t) (listVar).length; \
122110
++itemVarName)
123111

124112
#define FF_LIST_AUTO_DESTROY FFlist __attribute__((__cleanup__(ffListDestroy)))
125113

126-
#define FF_LIST_GET(itemType, listVar, index) \
127-
({ \
114+
#define FF_LIST_GET(itemType, listVar, index) \
115+
({ \
128116
assert(sizeof(itemType) == (listVar).elementSize); \
129-
assert((listVar).capacity > (index)); \
130-
(itemType*)(listVar).data + (index); \
117+
assert((listVar).capacity > (index)); \
118+
(itemType*) (listVar).data + (index); \
131119
})
132120

133-
#define FF_LIST_ADD(itemType, listVar) \
134-
({ \
121+
#define FF_LIST_ADD(itemType, listVar) \
122+
({ \
135123
assert(sizeof(itemType) == (listVar).elementSize); \
136-
(itemType*) ffListAdd(&(listVar)); \
124+
(itemType*) ffListAdd(&(listVar)); \
137125
})
138126

139127
#define FF_LIST_FIRST(itemType, listVar) FF_LIST_GET(itemType, listVar, 0)
140-
#define FF_LIST_LAST(itemType, listVar) \
141-
({ \
142-
assert((listVar).length > 0); \
128+
#define FF_LIST_LAST(itemType, listVar) \
129+
({ \
130+
assert((listVar).length > 0); \
143131
FF_LIST_GET(itemType, listVar, ((listVar).length - 1)); \
144132
})

0 commit comments

Comments
 (0)