Skip to content

Commit 96ac3cb

Browse files
this time
1 parent 9fa1a3b commit 96ac3cb

File tree

4 files changed

+0
-126
lines changed

4 files changed

+0
-126
lines changed

code/logic/fossil/sys/memory.h

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -154,28 +154,6 @@ fossil_sys_memory_t fossil_sys_memory_resize(fossil_sys_memory_t ptr, size_t old
154154
*/
155155
bool fossil_sys_memory_is_valid(const fossil_sys_memory_t ptr);
156156

157-
/**
158-
* @brief Align memory to a specific boundary.
159-
*
160-
* Allocates memory aligned to the specified alignment boundary.
161-
* Alignment must be a power of two (e.g., 8, 16, 32).
162-
*
163-
* @param size The size of the memory to allocate.
164-
* @param alignment The alignment boundary.
165-
* @return A pointer to the aligned memory.
166-
* @throws Error message and exits if allocation fails or alignment is invalid.
167-
*/
168-
fossil_sys_memory_t fossil_sys_memory_aligned_alloc(size_t size, size_t alignment);
169-
170-
/**
171-
* @brief Free aligned memory.
172-
*
173-
* Frees memory that was allocated with fossil_sys_memory_aligned_alloc.
174-
*
175-
* @param ptr A pointer to the aligned memory to free.
176-
*/
177-
void fossil_sys_memory_aligned_free(fossil_sys_memory_t ptr);
178-
179157
/**
180158
* @brief Fill memory with a repeating pattern.
181159
*
@@ -412,26 +390,6 @@ namespace fossil {
412390
return fossil_sys_memory_is_valid(ptr);
413391
}
414392

415-
/**
416-
* Allocate memory aligned to a specific boundary.
417-
*
418-
* @param size The size of the memory to allocate.
419-
* @param alignment The alignment boundary.
420-
* @return A pointer to the aligned memory.
421-
*/
422-
static fossil_sys_memory_t aligned_alloc(size_t size, size_t alignment) {
423-
return fossil_sys_memory_aligned_alloc(size, alignment);
424-
}
425-
426-
/**
427-
* Free aligned memory.
428-
*
429-
* @param ptr A pointer to the aligned memory to free.
430-
*/
431-
static void aligned_free(fossil_sys_memory_t ptr) {
432-
fossil_sys_memory_aligned_free(ptr);
433-
}
434-
435393
/**
436394
* Fill memory with a repeating pattern.
437395
*

code/logic/memory.c

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -192,44 +192,6 @@ bool fossil_sys_memory_is_valid(const fossil_sys_memory_t ptr) {
192192
return true;
193193
}
194194

195-
// ----------------------- Aligned Memory -----------------------
196-
197-
fossil_sys_memory_t fossil_sys_memory_aligned_alloc(size_t size, size_t alignment) {
198-
if (alignment == 0 || (alignment & (alignment - 1)) != 0) {
199-
fprintf(stderr, "Error: fossil_sys_memory_aligned_alloc() - Alignment must be a power of two.\n");
200-
return NULL;
201-
}
202-
203-
void *ptr = NULL;
204-
#if defined(_MSC_VER)
205-
ptr = _aligned_malloc(size, alignment);
206-
if (!ptr) {
207-
fprintf(stderr, "Error: fossil_sys_memory_aligned_alloc() - Aligned allocation failed.\n");
208-
return NULL;
209-
}
210-
#else
211-
if (posix_memalign(&ptr, alignment, size) != 0) {
212-
fprintf(stderr, "Error: fossil_sys_memory_aligned_alloc() - Aligned allocation failed.\n");
213-
return NULL;
214-
}
215-
#endif
216-
217-
g_alloc_count++;
218-
g_alloc_bytes += size;
219-
return ptr;
220-
}
221-
222-
void fossil_sys_memory_aligned_free(fossil_sys_memory_t ptr) {
223-
if (!ptr) return;
224-
225-
#if defined(_MSC_VER)
226-
_aligned_free(ptr);
227-
#else
228-
free(ptr);
229-
#endif
230-
// Note: g_alloc_count and g_alloc_bytes tracking could be refined with actual size bookkeeping
231-
}
232-
233195
// ----------------------- Memory Fill -----------------------
234196

235197
fossil_sys_memory_t fossil_sys_memory_fill(fossil_sys_memory_t ptr,

code/tests/cases/test_memory.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -168,23 +168,6 @@ FOSSIL_TEST(c_test_memory_init) {
168168
fossil_sys_memory_free(ptr); // Cleanup
169169
}
170170

171-
FOSSIL_TEST(c_test_memory_aligned_alloc_and_free) {
172-
size_t size = 64;
173-
size_t alignment = 16;
174-
fossil_sys_memory_t ptr = fossil_sys_memory_aligned_alloc(size, alignment);
175-
ASSUME_NOT_CNULL(ptr);
176-
// Check alignment
177-
ASSUME_ITS_TRUE(((uintptr_t)ptr % alignment) == 0);
178-
fossil_sys_memory_aligned_free(ptr);
179-
}
180-
181-
FOSSIL_TEST(c_test_memory_aligned_alloc_invalid_alignment) {
182-
size_t size = 32;
183-
size_t alignment = 20; // Not a power of two
184-
fossil_sys_memory_t ptr = fossil_sys_memory_aligned_alloc(size, alignment);
185-
ASSUME_ITS_TRUE(ptr == NULL);
186-
}
187-
188171
FOSSIL_TEST(c_test_memory_fill_pattern) {
189172
size_t size = 16;
190173
uint8_t pattern[2] = {0xAB, 0xCD};
@@ -236,13 +219,6 @@ FOSSIL_TEST(c_test_memory_strdup) {
236219
fossil_sys_memory_free(dup);
237220
}
238221

239-
FOSSIL_TEST(c_test_memory_stats) {
240-
size_t allocs = 0, bytes = 0;
241-
fossil_sys_memory_stats(&allocs, &bytes);
242-
// Just check that the function runs and returns something
243-
ASSUME_ITS_TRUE(allocs != 0 || bytes != 0);
244-
}
245-
246222
// * * * * * * * * * * * * * * * * * * * * * * * *
247223
// * Fossil Logic Test Pool
248224
// * * * * * * * * * * * * * * * * * * * * * * * *
@@ -258,14 +234,11 @@ FOSSIL_TEST_GROUP(c_memory_tests) {
258234
FOSSIL_TEST_ADD(c_memory_suite, c_test_memory_is_valid);
259235
FOSSIL_TEST_ADD(c_memory_suite, c_test_memory_calloc);
260236
FOSSIL_TEST_ADD(c_memory_suite, c_test_memory_init);
261-
FOSSIL_TEST_ADD(c_memory_suite, c_test_memory_aligned_alloc_and_free);
262-
FOSSIL_TEST_ADD(c_memory_suite, c_test_memory_aligned_alloc_invalid_alignment);
263237
FOSSIL_TEST_ADD(c_memory_suite, c_test_memory_fill_pattern);
264238
FOSSIL_TEST_ADD(c_memory_suite, c_test_memory_secure_zero);
265239
FOSSIL_TEST_ADD(c_memory_suite, c_test_memory_swap);
266240
FOSSIL_TEST_ADD(c_memory_suite, c_test_memory_find);
267241
FOSSIL_TEST_ADD(c_memory_suite, c_test_memory_strdup);
268-
FOSSIL_TEST_ADD(c_memory_suite, c_test_memory_stats);
269242

270243
FOSSIL_TEST_REGISTER(c_memory_suite);
271244
}

code/tests/cases/test_memory.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,6 @@ FOSSIL_TEST(cpp_test_memory_class_is_valid) {
323323
fossil::sys::Memory::free(ptr); // Cleanup
324324
}
325325

326-
FOSSIL_TEST(cpp_test_memory_class_aligned_alloc_free) {
327-
size_t size = 64;
328-
size_t alignment = 32;
329-
fossil_sys_memory_t ptr = fossil::sys::Memory::aligned_alloc(size, alignment);
330-
ASSUME_NOT_CNULL(ptr);
331-
ASSUME_ITS_TRUE(reinterpret_cast<uintptr_t>(ptr) % alignment == 0); // Check alignment
332-
fossil::sys::Memory::aligned_free(ptr); // Cleanup
333-
}
334-
335326
FOSSIL_TEST(cpp_test_memory_class_fill) {
336327
size_t size = 16;
337328
uint8_t pattern[2] = {0xAB, 0xCD};
@@ -406,14 +397,6 @@ FOSSIL_TEST(cpp_test_memory_class_strdup) {
406397
fossil::sys::Memory::free(dup); // Cleanup
407398
}
408399

409-
FOSSIL_TEST(cpp_test_memory_class_stats) {
410-
size_t allocs = 0, bytes = 0;
411-
fossil::sys::Memory::stats(&allocs, &bytes);
412-
// Just check that stats call does not crash and returns something
413-
ASSUME_ITS_TRUE(&allocs != nullptr);
414-
ASSUME_ITS_TRUE(&bytes != nullptr);
415-
}
416-
417400
// * * * * * * * * * * * * * * * * * * * * * * * *
418401
// * Fossil Logic Test Pool
419402
// * * * * * * * * * * * * * * * * * * * * * * * *
@@ -441,13 +424,11 @@ FOSSIL_TEST_GROUP(cpp_memory_tests) {
441424
FOSSIL_TEST_ADD(cpp_memory_suite, cpp_test_memory_class_move);
442425
FOSSIL_TEST_ADD(cpp_memory_suite, cpp_test_memory_class_resize);
443426
FOSSIL_TEST_ADD(cpp_memory_suite, cpp_test_memory_class_is_valid);
444-
FOSSIL_TEST_ADD(cpp_memory_suite, cpp_test_memory_class_aligned_alloc_free);
445427
FOSSIL_TEST_ADD(cpp_memory_suite, cpp_test_memory_class_fill);
446428
FOSSIL_TEST_ADD(cpp_memory_suite, cpp_test_memory_class_secure_zero);
447429
FOSSIL_TEST_ADD(cpp_memory_suite, cpp_test_memory_class_swap);
448430
FOSSIL_TEST_ADD(cpp_memory_suite, cpp_test_memory_class_find);
449431
FOSSIL_TEST_ADD(cpp_memory_suite, cpp_test_memory_class_strdup);
450-
FOSSIL_TEST_ADD(cpp_memory_suite, cpp_test_memory_class_stats);
451432

452433
FOSSIL_TEST_REGISTER(cpp_memory_suite);
453434
}

0 commit comments

Comments
 (0)