File include/jlib/assert.h changed (mode: 100644) (index 7439112..ad2b47a) |
2 |
2 |
#include <cstdio> |
#include <cstdio> |
3 |
3 |
#include <cstdlib> |
#include <cstdlib> |
4 |
4 |
|
|
|
5 |
|
|
5 |
6 |
#ifndef SOURCE_PATH_SIZE |
#ifndef SOURCE_PATH_SIZE |
6 |
7 |
#error SOURCE_PATH_SIZE must be size of path to project root directory, set macro in compiler options |
#error SOURCE_PATH_SIZE must be size of path to project root directory, set macro in compiler options |
7 |
8 |
#endif |
#endif |
|
15 |
16 |
#ifndef NDEBUG |
#ifndef NDEBUG |
16 |
17 |
#define jassert(Expr, Msg) jassert_release(Expr, Msg) |
#define jassert(Expr, Msg) jassert_release(Expr, Msg) |
17 |
18 |
#else |
#else |
18 |
|
#define jassert(Expr, Msg) ((void)Expr); |
|
|
19 |
|
#define jassert(Expr, Msg) ((void)(Expr)) |
19 |
20 |
#endif |
#endif |
20 |
21 |
namespace jl::details |
namespace jl::details |
21 |
22 |
{ |
{ |
|
... |
... |
namespace jl::details |
34 |
35 |
abort(msg, expr_str, file, line, func); |
abort(msg, expr_str, file, line, func); |
35 |
36 |
} |
} |
36 |
37 |
} |
} |
|
38 |
|
|
File include/jlib/rarray.h changed (mode: 100644) (index b13540c..5001c81) |
... |
... |
namespace jl |
93 |
93 |
* Same as rarray::init_move, but with different second argument |
* Same as rarray::init_move, but with different second argument |
94 |
94 |
* |
* |
95 |
95 |
* @param[in] p_allocated_mem Pointer to begin of already allocated memory. |
* @param[in] p_allocated_mem Pointer to begin of already allocated memory. |
96 |
|
* @param[in] allocated_mem_size Size of allocated memory. |
|
|
96 |
|
* @param[in] allocated_count Size of allocated memory in items count. |
97 |
97 |
* |
* |
98 |
98 |
* @see rarray::init_move |
* @see rarray::init_move |
99 |
99 |
*/ |
*/ |
100 |
|
void init_move(T *p_allocated_mem, size_t allocated_mem_size) |
|
101 |
|
{ |
|
102 |
|
init_move(p_allocated_mem, const_cast<T*>(reinterpret_cast<const T*>( |
|
103 |
|
reinterpret_cast<const uint8_t*>(p_allocated_mem) |
|
104 |
|
+ allocated_mem_size))); |
|
105 |
|
} |
|
|
100 |
|
void init_move(T *p_allocated_mem, size_t allocated_count) |
|
101 |
|
{ init_move(p_allocated_mem, p_allocated_mem + allocated_count); } |
106 |
102 |
|
|
107 |
103 |
/** |
/** |
108 |
104 |
* @brief Create rarray with already allocated memory. |
* @brief Create rarray with already allocated memory. |
|
... |
... |
namespace jl |
138 |
134 |
* @brief Create read-only rarray by pointer to array. |
* @brief Create read-only rarray by pointer to array. |
139 |
135 |
* |
* |
140 |
136 |
* @param[in] p_begin Pointer to begin of array. |
* @param[in] p_begin Pointer to begin of array. |
141 |
|
* @param[in] size Size of array in bytes. |
|
|
137 |
|
* @param[in] count Size of array in items count. |
142 |
138 |
* |
* |
143 |
139 |
* @return read-only rarray |
* @return read-only rarray |
144 |
140 |
*/ |
*/ |
145 |
|
[[nodiscard]] static rarray<const T> built_const(const T *p_begin, size_t size) |
|
146 |
|
{ |
|
147 |
|
return built_const(p_begin, |
|
148 |
|
reinterpret_cast<const T*>(reinterpret_cast<const uint8_t*>(p_begin) + size)); |
|
149 |
|
} |
|
|
141 |
|
[[nodiscard]] static rarray<const T> built_const(const T *p_begin, size_t count) |
|
142 |
|
{ return built_const(p_begin, p_begin + count); } |
150 |
143 |
/** |
/** |
151 |
144 |
* @brief Deallocate space, set item count to 0. |
* @brief Deallocate space, set item count to 0. |
152 |
145 |
* |
* |
|
... |
... |
namespace jl |
209 |
202 |
[[nodiscard]] size_t size_allocated() const { return size_t(p_end_allocated - p_begin); } |
[[nodiscard]] size_t size_allocated() const { return size_t(p_end_allocated - p_begin); } |
210 |
203 |
|
|
211 |
204 |
///@brief Count of items. |
///@brief Count of items. |
212 |
|
[[nodiscard]] size_t count() const { return size_t(end() - begin()); } |
|
|
205 |
|
[[nodiscard]] size_t count() const { return size_t(end() - begin()); } |
|
206 |
|
/// @brief Count of items in 32-bit unsigned integer. |
|
207 |
|
[[nodiscard]] uint32_t count32() const { return uint32_t(count()); } |
|
208 |
|
/// @brief Count of items in 16-bit unsigned integer. |
|
209 |
|
[[nodiscard]] uint16_t count16() const { return uint16_t(count()); } |
|
210 |
|
/// @brief Count of items in 8-bit unsugned integer. |
|
211 |
|
[[nodiscard]] uint8_t count8() const { return uint8_t (count()); } |
213 |
212 |
|
|
214 |
213 |
/// @brief Get pointer to an allocated memory. |
/// @brief Get pointer to an allocated memory. |
215 |
214 |
[[nodiscard]] T* begin() { return reinterpret_cast<T*>(p_begin); } |
[[nodiscard]] T* begin() { return reinterpret_cast<T*>(p_begin); } |