Skip to content

Commit 6f4d286

Browse files
committed
Apply new .clang-format
1 parent d5a595e commit 6f4d286

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

.clang-format

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ AlignConsecutiveBitFields:
1616
AlignConsecutiveDeclarations: None
1717
AlignEscapedNewlines: Right
1818
AlignOperands: Align
19-
SortIncludes: false
19+
SortIncludes: true
2020
InsertBraces: true # Control statements must have curly brackets
2121
AlignTrailingComments: true
2222
AllowAllArgumentsOnNextLine: true
2323
AllowAllParametersOfDeclarationOnNextLine: true
2424
AllowShortEnumsOnASingleLine: true
2525
AllowShortBlocksOnASingleLine: Empty
26-
AllowShortCaseLabelsOnASingleLine: false
26+
AllowShortCaseLabelsOnASingleLine: true
2727
AllowShortFunctionsOnASingleLine: All
2828
AllowShortLambdasOnASingleLine: All
2929
AllowShortIfStatementsOnASingleLine: Never

lwmem/src/include/lwmem/lwmem.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#define LWMEM_HDR_H
3636

3737
#include <limits.h>
38-
#include <stdint.h>
3938
#include <stddef.h>
39+
#include <stdint.h>
4040
#include "lwmem/lwmem_opt.h"
4141

4242
#ifdef __cplusplus

lwmem/src/lwmem/lwmem.c

+17-17
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@
124124
*
125125
* Default size is size of meta block
126126
*/
127-
#define LWMEM_BLOCK_MIN_SIZE (LWMEM_BLOCK_META_SIZE)
127+
#define LWMEM_BLOCK_MIN_SIZE (LWMEM_BLOCK_META_SIZE)
128128

129129
/**
130130
* \brief Get LwMEM instance based on user input
131131
* \param[in] in_lwobj: LwMEM instance. Set to `NULL` for default instance
132132
*/
133-
#define LWMEM_GET_LWOBJ(in_lwobj) ((in_lwobj) != NULL ? (in_lwobj) : (&lwmem_default))
133+
#define LWMEM_GET_LWOBJ(in_lwobj) ((in_lwobj) != NULL ? (in_lwobj) : (&lwmem_default))
134134

135135
/**
136136
* \brief Gets block before input block (marked as prev) and its previous free block
@@ -139,9 +139,9 @@
139139
* \param[in] in_pp: Previous previous of input block
140140
* \param[in] in_p: Previous of input block
141141
*/
142-
#define LWMEM_GET_PREV_CURR_OF_BLOCK(in_lwobj, in_b, in_pp, in_p) \
142+
#define LWMEM_GET_PREV_CURR_OF_BLOCK(in_lwobj, in_b, in_pp, in_p) \
143143
do { \
144-
for ((in_pp) = NULL, (in_p) = &((in_lwobj)->start_block); (in_p) != NULL && (in_p)->next < (in_b); \
144+
for ((in_pp) = NULL, (in_p) = &((in_lwobj)->start_block); (in_p) != NULL && (in_p)->next < (in_b); \
145145
(in_pp) = (in_p), (in_p) = (in_p)->next) {} \
146146
} while (0)
147147

@@ -156,10 +156,10 @@
156156
/* Statistics part */
157157
#if LWMEM_CFG_ENABLE_STATS
158158
#define LWMEM_INC_STATS(field) (++(field))
159-
#define LWMEM_UPDATE_MIN_FREE(lwobj) \
159+
#define LWMEM_UPDATE_MIN_FREE(lwobj) \
160160
do { \
161-
if ((lwobj)->mem_available_bytes < (lwobj)->stats.minimum_ever_mem_available_bytes) { \
162-
(lwobj)->stats.minimum_ever_mem_available_bytes = (lwobj)->mem_available_bytes; \
161+
if ((lwobj)->mem_available_bytes < (lwobj)->stats.minimum_ever_mem_available_bytes) { \
162+
(lwobj)->stats.minimum_ever_mem_available_bytes = (lwobj)->mem_available_bytes; \
163163
} \
164164
} while (0)
165165
#else
@@ -369,7 +369,7 @@ prv_alloc(lwmem_t* const lwobj, const lwmem_region_t* region, const size_t size)
369369

370370
/* Set default values */
371371
prev = &(lwobj->start_block); /* Use pointer from custom lwmem block */
372-
curr = prev->next; /* Curr represents first actual free block */
372+
curr = prev->next; /* Curr represents first actual free block */
373373

374374
/*
375375
* If region is not set to NULL,
@@ -431,7 +431,7 @@ prv_alloc(lwmem_t* const lwobj, const lwmem_region_t* region, const size_t size)
431431

432432
lwobj->mem_available_bytes -= curr->size; /* Decrease available bytes by allocated block size */
433433
prv_split_too_big_block(lwobj, curr, final_size); /* Split block if it is too big */
434-
LWMEM_BLOCK_SET_ALLOC(curr); /* Set block as allocated */
434+
LWMEM_BLOCK_SET_ALLOC(curr); /* Set block as allocated */
435435

436436
LWMEM_UPDATE_MIN_FREE(lwobj);
437437
LWMEM_INC_STATS(lwobj->stats.nr_alloc);
@@ -592,8 +592,8 @@ prv_realloc(lwmem_t* const lwobj, const lwmem_region_t* region, void* const ptr,
592592
prev->next->next; /* Set next to next's next, effectively remove expanded block from free list */
593593

594594
prv_split_too_big_block(lwobj, block, final_size); /* Split block if it is too big */
595-
LWMEM_BLOCK_SET_ALLOC(block); /* Set block as allocated */
596-
return ptr; /* Return existing pointer */
595+
LWMEM_BLOCK_SET_ALLOC(block); /* Set block as allocated */
596+
return ptr; /* Return existing pointer */
597597
}
598598

599599
/*
@@ -625,8 +625,8 @@ prv_realloc(lwmem_t* const lwobj, const lwmem_region_t* region, void* const ptr,
625625
block = prev; /* Move block pointer to previous one */
626626

627627
prv_split_too_big_block(lwobj, block, final_size); /* Split block if it is too big */
628-
LWMEM_BLOCK_SET_ALLOC(block); /* Set block as allocated */
629-
return new_data_ptr; /* Return new data ptr */
628+
LWMEM_BLOCK_SET_ALLOC(block); /* Set block as allocated */
629+
return new_data_ptr; /* Return new data ptr */
630630
}
631631

632632
/*
@@ -669,8 +669,8 @@ prv_realloc(lwmem_t* const lwobj, const lwmem_region_t* region, void* const ptr,
669669
block = prev; /* Previous block is now current */
670670

671671
prv_split_too_big_block(lwobj, block, final_size); /* Split block if it is too big */
672-
LWMEM_BLOCK_SET_ALLOC(block); /* Set block as allocated */
673-
return new_data_ptr; /* Return new data ptr */
672+
LWMEM_BLOCK_SET_ALLOC(block); /* Set block as allocated */
673+
return new_data_ptr; /* Return new data ptr */
674674
}
675675
} else {
676676
/* Hard error. Input pointer is not NULL and block is not considered allocated */
@@ -691,7 +691,7 @@ prv_realloc(lwmem_t* const lwobj, const lwmem_region_t* region, void* const ptr,
691691
block_size =
692692
(block->size & ~LWMEM_ALLOC_BIT) - LWMEM_BLOCK_META_SIZE; /* Get application size from input pointer */
693693
LWMEM_MEMCPY(retval, ptr, size > block_size ? block_size : size); /* Copy content to new allocated block */
694-
prv_free(lwobj, ptr); /* Free input pointer */
694+
prv_free(lwobj, ptr); /* Free input pointer */
695695
}
696696
return retval;
697697
}
@@ -760,7 +760,7 @@ lwmem_assignmem_ex(lwmem_t* lwobj, const lwmem_region_t* regions) {
760760
#if LWMEM_CFG_OS
761761
|| lwmem_sys_mutex_isvalid(&(lwobj->mutex)) /* Check if mutex valid already = must not be */
762762
|| !lwmem_sys_mutex_create(&(lwobj->mutex)) /* Final step = try to create mutex for new instance */
763-
#endif /* LWMEM_CFG_OS */
763+
#endif /* LWMEM_CFG_OS */
764764
) {
765765
return 0;
766766
}

0 commit comments

Comments
 (0)