Skip to content

Commit c60ffc6

Browse files
Merge branch 'unstable' into test-zipmap
2 parents a3b0576 + a0aebb6 commit c60ffc6

File tree

140 files changed

+24985
-27234
lines changed

Some content is hidden

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

140 files changed

+24985
-27234
lines changed

src/.clang-format

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
BasedOnStyle: LLVM
2+
IndentWidth: 4
3+
TabWidth: 4
4+
UseTab: Never
5+
ColumnLimit: 120
6+
PenaltyBreakComment: 300
7+
PenaltyBreakFirstLessLess: 120
8+
PenaltyBreakString: 100
9+
PenaltyExcessCharacter: 100
10+
MaxEmptyLinesToKeep: 2
11+
BreakBeforeBraces: Attach
12+
AllowShortCaseLabelsOnASingleLine: true
13+
AllowShortIfStatementsOnASingleLine: WithoutElse
14+
AllowShortLoopsOnASingleLine: true
15+
AllowShortFunctionsOnASingleLine: false
16+
AlignConsecutiveAssignments: false
17+
AlignConsecutiveDeclarations: false
18+
AlignTrailingComments: true
19+
PointerAlignment: Right
20+
KeepEmptyLinesAtTheStartOfBlocks: false
21+
SpaceBeforeParens: ControlStatements
22+
SpacesInParentheses: false
23+
SpacesInAngles: false
24+
SpacesInCStyleCastParentheses: false
25+
SpaceAfterCStyleCast: false
26+
SpacesInSquareBrackets: false
27+
ReflowComments: true
28+
CommentPragmas: '^\\s*\\*'
29+
SortIncludes: false
30+
AllowAllParametersOfDeclarationOnNextLine: false
31+
BinPackParameters: false
32+
AlignAfterOpenBracket: Align

src/.clang-format-ignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Don't format files copied from other sources.
22
lzf*
33
crccombine.*
4+
crc16.c
5+
crc16_slottable.h
6+
crc64.c
47
crcspeed.*
8+
fmtargs.h
59
mt19937-64.*
610
pqsort.*
711
setcpuaffinity.c

src/acl.c

Lines changed: 550 additions & 591 deletions
Large diffs are not rendered by default.

src/adlist.c

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@
3939
* listSetFreeMethod.
4040
*
4141
* On error, NULL is returned. Otherwise the pointer to the new list. */
42-
list *listCreate(void)
43-
{
42+
list *listCreate(void) {
4443
struct list *list;
4544

46-
if ((list = zmalloc(sizeof(*list))) == NULL)
47-
return NULL;
45+
if ((list = zmalloc(sizeof(*list))) == NULL) return NULL;
4846
list->head = list->tail = NULL;
4947
list->len = 0;
5048
list->dup = NULL;
@@ -54,14 +52,13 @@ list *listCreate(void)
5452
}
5553

5654
/* Remove all the elements from the list without destroying the list itself. */
57-
void listEmpty(list *list)
58-
{
55+
void listEmpty(list *list) {
5956
unsigned long len;
6057
listNode *current, *next;
6158

6259
current = list->head;
6360
len = list->len;
64-
while(len--) {
61+
while (len--) {
6562
next = current->next;
6663
if (list->free) list->free(current->value);
6764
zfree(current);
@@ -74,10 +71,8 @@ void listEmpty(list *list)
7471
/* Free the whole list.
7572
*
7673
* This function can't fail. */
77-
void listRelease(list *list)
78-
{
79-
if (!list)
80-
return;
74+
void listRelease(list *list) {
75+
if (!list) return;
8176
listEmpty(list);
8277
zfree(list);
8378
}
@@ -88,12 +83,10 @@ void listRelease(list *list)
8883
* On error, NULL is returned and no operation is performed (i.e. the
8984
* list remains unaltered).
9085
* On success the 'list' pointer you pass to the function is returned. */
91-
list *listAddNodeHead(list *list, void *value)
92-
{
86+
list *listAddNodeHead(list *list, void *value) {
9387
listNode *node;
9488

95-
if ((node = zmalloc(sizeof(*node))) == NULL)
96-
return NULL;
89+
if ((node = zmalloc(sizeof(*node))) == NULL) return NULL;
9790
node->value = value;
9891
listLinkNodeHead(list, node);
9992
return list;
@@ -102,7 +95,7 @@ list *listAddNodeHead(list *list, void *value)
10295
/*
10396
* Add a node that has already been allocated to the head of list
10497
*/
105-
void listLinkNodeHead(list* list, listNode *node) {
98+
void listLinkNodeHead(list *list, listNode *node) {
10699
if (list->len == 0) {
107100
list->head = list->tail = node;
108101
node->prev = node->next = NULL;
@@ -121,12 +114,10 @@ void listLinkNodeHead(list* list, listNode *node) {
121114
* On error, NULL is returned and no operation is performed (i.e. the
122115
* list remains unaltered).
123116
* On success the 'list' pointer you pass to the function is returned. */
124-
list *listAddNodeTail(list *list, void *value)
125-
{
117+
list *listAddNodeTail(list *list, void *value) {
126118
listNode *node;
127119

128-
if ((node = zmalloc(sizeof(*node))) == NULL)
129-
return NULL;
120+
if ((node = zmalloc(sizeof(*node))) == NULL) return NULL;
130121
node->value = value;
131122
listLinkNodeTail(list, node);
132123
return list;
@@ -151,8 +142,7 @@ void listLinkNodeTail(list *list, listNode *node) {
151142
list *listInsertNode(list *list, listNode *old_node, void *value, int after) {
152143
listNode *node;
153144

154-
if ((node = zmalloc(sizeof(*node))) == NULL)
155-
return NULL;
145+
if ((node = zmalloc(sizeof(*node))) == NULL) return NULL;
156146
node->value = value;
157147
if (after) {
158148
node->prev = old_node;
@@ -181,8 +171,7 @@ list *listInsertNode(list *list, listNode *old_node, void *value, int after) {
181171
* The node is freed. If free callback is provided the value is freed as well.
182172
*
183173
* This function can't fail. */
184-
void listDelNode(list *list, listNode *node)
185-
{
174+
void listDelNode(list *list, listNode *node) {
186175
listUnlinkNode(list, node);
187176
if (list->free) list->free(node->value);
188177
zfree(node);
@@ -211,8 +200,7 @@ void listUnlinkNode(list *list, listNode *node) {
211200
* call to listNext() will return the next element of the list.
212201
*
213202
* This function can't fail. */
214-
listIter *listGetIterator(list *list, int direction)
215-
{
203+
listIter *listGetIterator(list *list, int direction) {
216204
listIter *iter;
217205

218206
if ((iter = zmalloc(sizeof(*iter))) == NULL) return NULL;
@@ -254,8 +242,7 @@ void listRewindTail(list *list, listIter *li) {
254242
* }
255243
*
256244
* */
257-
listNode *listNext(listIter *iter)
258-
{
245+
listNode *listNext(listIter *iter) {
259246
listNode *current = iter->next;
260247

261248
if (current != NULL) {
@@ -275,19 +262,17 @@ listNode *listNext(listIter *iter)
275262
* the original node is used as value of the copied node.
276263
*
277264
* The original list both on success or error is never modified. */
278-
list *listDup(list *orig)
279-
{
265+
list *listDup(list *orig) {
280266
list *copy;
281267
listIter iter;
282268
listNode *node;
283269

284-
if ((copy = listCreate()) == NULL)
285-
return NULL;
270+
if ((copy = listCreate()) == NULL) return NULL;
286271
copy->dup = orig->dup;
287272
copy->free = orig->free;
288273
copy->match = orig->match;
289274
listRewind(orig, &iter);
290-
while((node = listNext(&iter)) != NULL) {
275+
while ((node = listNext(&iter)) != NULL) {
291276
void *value;
292277

293278
if (copy->dup) {
@@ -299,7 +284,7 @@ list *listDup(list *orig)
299284
} else {
300285
value = node->value;
301286
}
302-
287+
303288
if (listAddNodeTail(copy, value) == NULL) {
304289
/* Free value if dup succeed but listAddNodeTail failed. */
305290
if (copy->free) copy->free(value);
@@ -320,13 +305,12 @@ list *listDup(list *orig)
320305
* On success the first matching node pointer is returned
321306
* (search starts from head). If no matching node exists
322307
* NULL is returned. */
323-
listNode *listSearchKey(list *list, void *key)
324-
{
308+
listNode *listSearchKey(list *list, void *key) {
325309
listIter iter;
326310
listNode *node;
327311

328312
listRewind(list, &iter);
329-
while((node = listNext(&iter)) != NULL) {
313+
while ((node = listNext(&iter)) != NULL) {
330314
if (list->match) {
331315
if (list->match(node->value, key)) {
332316
return node;
@@ -349,12 +333,12 @@ listNode *listIndex(list *list, long index) {
349333
listNode *n;
350334

351335
if (index < 0) {
352-
index = (-index)-1;
336+
index = (-index) - 1;
353337
n = list->tail;
354-
while(index-- && n) n = n->prev;
338+
while (index-- && n) n = n->prev;
355339
} else {
356340
n = list->head;
357-
while(index-- && n) n = n->next;
341+
while (index-- && n) n = n->next;
358342
}
359343
return n;
360344
}

src/adlist.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ typedef struct list {
6161
#define listNextNode(n) ((n)->next)
6262
#define listNodeValue(n) ((n)->value)
6363

64-
#define listSetDupMethod(l,m) ((l)->dup = (m))
65-
#define listSetFreeMethod(l,m) ((l)->free = (m))
66-
#define listSetMatchMethod(l,m) ((l)->match = (m))
64+
#define listSetDupMethod(l, m) ((l)->dup = (m))
65+
#define listSetFreeMethod(l, m) ((l)->free = (m))
66+
#define listSetMatchMethod(l, m) ((l)->match = (m))
6767

6868
#define listGetDupMethod(l) ((l)->dup)
6969
#define listGetFreeMethod(l) ((l)->free)

0 commit comments

Comments
 (0)