LibJuno 0.22.0
LibJuno is a lightweight C99 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
memory_block.h
Go to the documentation of this file.
1/*
2 MIT License
3
4 Copyright (c) 2025 Robin A. Onsay
5
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files
8 (the "Software"), to deal in the Software without restriction,
9 including without limitation the rights to use, copy, modify, merge,
10 publish, distribute, sublicense, and/or sell copies of the Software,
11 and to permit persons to whom the Software is furnished to do so,
12 subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be
15 included in all copies or substantial portions of the Software.
16*/
17
27#ifndef JUNO_MEMORY_BLOCK_H
28#define JUNO_MEMORY_BLOCK_H
29#include "juno/module.h"
30#include "juno/status.h"
32#ifdef __cplusplus
33extern "C"
34{
35#endif
36
37
38JUNO_MODULE_DERIVE_DECLARE(JUNO_MEMORY_ALLOC_BLOCK_T);
39
40JUNO_MODULE_DERIVE(JUNO_MEMORY_ALLOC_BLOCK_T, JUNO_MEMORY_ALLOC_BASE_T,
41 uint8_t *pvMemory;
43 size_t zTypeSize;
44 size_t zLength;
45 size_t zUsed;
46 size_t zFreed;
47);
48
49#ifdef JUNO_MEMORY_DEFAULT
59JUNO_MODULE(JUNO_MEMORY_ALLOC_T, JUNO_MEMORY_ALLOC_API_T, JUNO_MEMORY_ALLOC_BASE_T,
60 JUNO_MEMORY_ALLOC_BLOCK_T tJunoMemoryBlock;
61);
62#endif
63
74JUNO_STATUS_T JunoMemory_BlockApi(JUNO_MEMORY_ALLOC_T *ptJunoMemory,
75 void *pvMemory,
77 size_t zTypeSize,
78 size_t zLength,
79 JUNO_FAILURE_HANDLER_T pfcnFailureHandler,
80 JUNO_USER_DATA_T *pvFailureUserData
81);
82#ifdef __cplusplus
83}
84#endif
85#endif // JUNO_MEMORY_BLOCK_H
86
JUNO_STATUS_T JunoMemory_BlockApi(JUNO_MEMORY_ALLOC_T *ptJunoMemory, void *pvMemory, JUNO_MEMORY_BLOCK_METADATA_T *ptMetadata, size_t zTypeSize, size_t zLength, JUNO_FAILURE_HANDLER_T pfcnFailureHandler, JUNO_USER_DATA_T *pvFailureUserData)
Initializes a memory block for allocation. Sets up a memory block with an associated free stack for m...
Definition juno_memory_block.c:194
#define JUNO_MODULE_DERIVE_DECLARE(name)
Definition module.h:36
#define JUNO_MODULE(name, API, base, derived)
Definition module.h:67
#define JUNO_MODULE_DERIVE(name, base, members)
Definition module.h:96
void(* JUNO_FAILURE_HANDLER_T)(JUNO_STATUS_T tStatus, const char *pcCustomMessage, JUNO_USER_DATA_T *pvUserData)
Definition status.h:44
enum JUNO_STATUS_TAG JUNO_STATUS_T
void JUNO_USER_DATA_T
Definition status.h:43
Definition memory_api.h:82
The memory metadata.
Definition memory_api.h:58