chore: clang-format and formatting
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
BasedOnStyle: LLVM
|
||||
|
||||
# Pointer/Reference alignment: int * p, void (* callback)(...)
|
||||
PointerAlignment: Middle
|
||||
ReferenceAlignment: Middle
|
||||
|
||||
# Line length
|
||||
ColumnLimit: 100
|
||||
|
||||
# Return type on its own line
|
||||
BreakAfterReturnType: All
|
||||
|
||||
# Params each on their own line
|
||||
BinPackParameters: false
|
||||
|
||||
# Indentation
|
||||
IndentWidth: 4
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
ContinuationIndentWidth: 4
|
||||
|
||||
# Braces always on their own line (Allman style)
|
||||
BreakBeforeBraces: Allman
|
||||
|
||||
# No blank line after opening {
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
|
||||
# Space after C-style cast: (uint32_t) x
|
||||
SpaceAfterCStyleCast: true
|
||||
|
||||
# Spaces
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
|
||||
# Allow single-line if without braces
|
||||
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||
|
||||
# Include sorting
|
||||
SortIncludes: CaseSensitive
|
||||
IncludeBlocks: Regroup
|
||||
|
||||
# Short constructs
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
|
||||
# Comments
|
||||
ReflowComments: true
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
Checks: >
|
||||
bugprone-*,
|
||||
cert-*,
|
||||
clang-analyzer-*,
|
||||
misc-*,
|
||||
performance-*,
|
||||
portability-*,
|
||||
readability-*,
|
||||
-readability-magic-numbers,
|
||||
-readability-identifier-length,
|
||||
-readability-function-cognitive-complexity,
|
||||
-readability-braces-around-statements,
|
||||
-cert-err33-c,
|
||||
-misc-include-cleaner
|
||||
|
||||
CheckOptions:
|
||||
- key: bugprone-easily-swappable-parameters.MinimumLength
|
||||
value: 3
|
||||
- key: readability-identifier-naming.FunctionCase
|
||||
value: lower_case
|
||||
- key: readability-identifier-naming.VariableCase
|
||||
value: lower_case
|
||||
- key: readability-identifier-naming.MacroDefinitionCase
|
||||
value: UPPER_CASE
|
||||
- key: readability-identifier-naming.TypedefCase
|
||||
value: CamelCase
|
||||
|
||||
HeaderFilterRegex: '.*'
|
||||
FormatStyle: file
|
||||
+14
-80
@@ -2,112 +2,46 @@
|
||||
#ifndef PAULDB_STORAGE_H
|
||||
#define PAULDB_STORAGE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
|
||||
#endif
|
||||
|
||||
/* --- Page Management --- */
|
||||
typedef struct Page Page;
|
||||
|
||||
Page *
|
||||
page_create
|
||||
(
|
||||
uint32_t page_id
|
||||
);
|
||||
Page * page_create(uint32_t page_id);
|
||||
|
||||
int
|
||||
page_insert
|
||||
(
|
||||
Page *p,
|
||||
const void *data,
|
||||
size_t len
|
||||
);
|
||||
int page_insert(Page * p, const void * data, size_t len);
|
||||
|
||||
void *
|
||||
page_get
|
||||
(
|
||||
Page *p,
|
||||
uint16_t slot_id,
|
||||
size_t *out_len
|
||||
);
|
||||
void * page_get(Page * p, uint16_t slot_id, size_t * out_len);
|
||||
|
||||
void
|
||||
page_free
|
||||
(
|
||||
Page *p
|
||||
);
|
||||
void page_free(Page * p);
|
||||
|
||||
/* --- Heap (Multi-Page Row Store / Delta) --- */
|
||||
typedef struct Heap Heap;
|
||||
|
||||
Heap *
|
||||
heap_create
|
||||
(
|
||||
void
|
||||
);
|
||||
Heap * heap_create(void);
|
||||
|
||||
int
|
||||
heap_insert
|
||||
(
|
||||
Heap *h,
|
||||
const void *data,
|
||||
size_t len
|
||||
);
|
||||
int heap_insert(Heap * h, const void * data, size_t len);
|
||||
|
||||
void
|
||||
heap_full_scan
|
||||
(
|
||||
Heap *h,
|
||||
void (*callback)
|
||||
(
|
||||
const void *,
|
||||
size_t
|
||||
)
|
||||
);
|
||||
void heap_full_scan(Heap * h, void (*callback)(const void *, size_t));
|
||||
|
||||
void
|
||||
heap_free
|
||||
(
|
||||
Heap *h
|
||||
);
|
||||
void heap_free(Heap * h);
|
||||
|
||||
/* --- B+Tree Index --- */
|
||||
typedef struct BTree BTree;
|
||||
|
||||
BTree *
|
||||
btree_create
|
||||
(
|
||||
void
|
||||
);
|
||||
BTree * btree_create(void);
|
||||
|
||||
int
|
||||
btree_insert
|
||||
(
|
||||
BTree *bt,
|
||||
int64_t key,
|
||||
uint32_t page_id,
|
||||
uint16_t slot_id
|
||||
);
|
||||
int btree_insert(BTree * bt, int64_t key, uint32_t page_id, uint16_t slot_id);
|
||||
|
||||
int
|
||||
btree_lookup
|
||||
(
|
||||
BTree *bt,
|
||||
int64_t key,
|
||||
uint32_t *out_page,
|
||||
uint16_t *out_slot
|
||||
);
|
||||
int btree_lookup(BTree * bt, int64_t key, uint32_t * out_page, uint16_t * out_slot);
|
||||
|
||||
void
|
||||
btree_free
|
||||
(
|
||||
BTree *bt
|
||||
);
|
||||
void btree_free(BTree * bt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+6
-26
@@ -46,10 +46,7 @@ struct Page
|
||||
/* ---- Hilfsfunktionen ---- */
|
||||
|
||||
static PageHeader *
|
||||
header
|
||||
(
|
||||
Page *p
|
||||
)
|
||||
header(Page * p)
|
||||
{
|
||||
return (PageHeader *) p->raw;
|
||||
}
|
||||
@@ -57,14 +54,10 @@ header
|
||||
/* ---- API ---- */
|
||||
|
||||
Page *
|
||||
page_create
|
||||
(
|
||||
uint32_t page_id
|
||||
)
|
||||
page_create(uint32_t page_id)
|
||||
{
|
||||
Page * p = malloc(sizeof(Page));
|
||||
if (!p)
|
||||
return NULL;
|
||||
if (!p) return NULL;
|
||||
|
||||
memset(p->raw, 0, PAGE_SIZE);
|
||||
|
||||
@@ -77,22 +70,14 @@ page_create
|
||||
}
|
||||
|
||||
void
|
||||
page_free
|
||||
(
|
||||
Page *p
|
||||
)
|
||||
page_free(Page * p)
|
||||
{
|
||||
free(p);
|
||||
}
|
||||
|
||||
/* page_insert und page_get folgen im naechsten TDD-Zyklus */
|
||||
int
|
||||
page_insert
|
||||
(
|
||||
Page *p,
|
||||
const void *data,
|
||||
size_t len
|
||||
)
|
||||
page_insert(Page * p, const void * data, size_t len)
|
||||
{
|
||||
(void) p;
|
||||
(void) data;
|
||||
@@ -101,12 +86,7 @@ page_insert
|
||||
}
|
||||
|
||||
void *
|
||||
page_get
|
||||
(
|
||||
Page *p,
|
||||
uint16_t slot_id,
|
||||
size_t *out_len
|
||||
)
|
||||
page_get(Page * p, uint16_t slot_id, size_t * out_len)
|
||||
{
|
||||
(void) p;
|
||||
(void) slot_id;
|
||||
|
||||
@@ -4,16 +4,13 @@
|
||||
* RED -> diese Datei schreiben, noch kein page.c -> Linker-Fehler
|
||||
* GREEN -> page_create() + page_free() in page.c implementieren
|
||||
*/
|
||||
#include "pauldb/storage.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "pauldb/storage.h"
|
||||
|
||||
static void
|
||||
test_create_returns_non_null
|
||||
(
|
||||
void
|
||||
)
|
||||
test_create_returns_non_null(void)
|
||||
{
|
||||
Page * p = page_create(42);
|
||||
assert(p != NULL);
|
||||
@@ -21,11 +18,10 @@ test_create_returns_non_null
|
||||
printf(" OK: page_create(42) returns non-NULL\n");
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
int
|
||||
main
|
||||
(
|
||||
void
|
||||
)
|
||||
main(void)
|
||||
{
|
||||
printf("=== test_page ===\n");
|
||||
test_create_returns_non_null();
|
||||
|
||||
Reference in New Issue
Block a user