mirror of
https://github.com/tailix/libkernaux.git
synced 2025-04-14 17:32:55 -04:00
Main: CONTRIBUTING.md: add a rule
This commit is contained in:
parent
0536bc47d5
commit
8503637778
4 changed files with 43 additions and 4 deletions
|
@ -10,7 +10,40 @@ Common
|
|||
C language
|
||||
----------
|
||||
|
||||
Nothing here yet.
|
||||
* Create `typedef`s with the names of related `struct`s. Use this name with a
|
||||
prefix `struct` to declare the data itself, withoth the prefix to declare
|
||||
a pointer or an array:
|
||||
|
||||
```c
|
||||
typedef struct FooBar { int car; } *FooBar;
|
||||
|
||||
static struct FooBar FooBar_create();
|
||||
static void FooBar_do_something(FooBar foobar);
|
||||
|
||||
// ...
|
||||
|
||||
struct FooBar foobar = FooBar_create();
|
||||
FooBar foobar_ptr = &foobar;
|
||||
FooBar_do_something(&foobar);
|
||||
```
|
||||
|
||||
```c
|
||||
typedef struct FooBar { int car; } FooBar[1];
|
||||
|
||||
static struct FooBar FooBar_create();
|
||||
static void FooBar FooBar_init(FooBar foobar);
|
||||
|
||||
static void FooBar_do_something(FooBar foobar);
|
||||
|
||||
// ...
|
||||
|
||||
FooBar foobar = { FooBar_create() };
|
||||
// or
|
||||
FooBar foobar;
|
||||
FooBar_init(foobar);
|
||||
|
||||
FooBar_do_something(foobar);
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -8,11 +8,9 @@
|
|||
#define SIZE_512MiB ( 512 * 1024 * 1024)
|
||||
#define SIZE_1GiB (1024 * 1024 * 1024)
|
||||
|
||||
KernAux_MemMap memmap;
|
||||
|
||||
int main()
|
||||
{
|
||||
KernAux_MemMap_init(memmap, SIZE_1GiB);
|
||||
KernAux_MemMap memmap = { KernAux_MemMap_create(SIZE_1GiB) };
|
||||
|
||||
assert(KernAux_MemMap_add_entry(memmap, true, NULL, 0, SIZE_256MiB));
|
||||
assert(KernAux_MemMap_add_entry(memmap, false, "foo", SIZE_256MiB, SIZE_256MiB));
|
||||
|
|
|
@ -26,6 +26,7 @@ typedef struct KernAux_MemMap {
|
|||
struct KernAux_MemMap_Entry entries[KERNAUX_MEMMAP_ENTRIES_MAX];
|
||||
} KernAux_MemMap[1];
|
||||
|
||||
struct KernAux_MemMap KernAux_MemMap_create(size_t memory_size);
|
||||
void KernAux_MemMap_init(KernAux_MemMap memmap, size_t memory_size);
|
||||
|
||||
/// @warning Must only be called with unfinished memmap, otherwise panics.
|
||||
|
|
|
@ -12,6 +12,13 @@
|
|||
|
||||
#define MEMMAP (*memmap)
|
||||
|
||||
struct KernAux_MemMap KernAux_MemMap_create(const size_t memory_size)
|
||||
{
|
||||
struct KernAux_MemMap memmap;
|
||||
KernAux_MemMap_init(&memmap, memory_size);
|
||||
return memmap;
|
||||
}
|
||||
|
||||
void KernAux_MemMap_init(KernAux_MemMap memmap, const size_t memory_size)
|
||||
{
|
||||
MEMMAP.is_finished = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue