Skip to content

Add realloc and remove redundancies#33

Merged
pavel-kirienko merged 22 commits intomasterfrom
dev
Jan 21, 2026
Merged

Add realloc and remove redundancies#33
pavel-kirienko merged 22 commits intomasterfrom
dev

Conversation

@pavel-kirienko
Copy link
Owner

Closes #21

@pavel-kirienko pavel-kirienko marked this pull request as ready for review January 21, 2026 22:24
@pavel-kirienko pavel-kirienko enabled auto-merge (squash) January 21, 2026 22:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds o1heapReallocate functionality to enable efficient memory reallocation with constant-time complexity in most cases, addressing issue #21. The implementation includes comprehensive optimization of internal functions and removal of the trace functionality that was added in v2.2.

Changes:

  • Adds o1heapReallocate() API with multiple strategies: shrink-in-place, expand-forward, expand-backward, and alloc-copy-free fallback
  • Removes log2Ceil function (optimization: reuses log2Floor where quotients are powers of 2)
  • Optimizes rebin/unbin by passing fragment sizes as parameters to avoid redundant fragGetSize calls
  • Removes trace functionality (O1HEAP_TRACE, o1heapTraceAllocate, o1heapTraceFree)
  • Adds comprehensive test coverage for all realloc scenarios including edge cases

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
o1heap/o1heap.c Implements o1heapReallocate with 4 strategies; optimizes rebin/unbin; removes log2Ceil and trace; adds larger() helper
o1heap/o1heap.h Documents new o1heapReallocate API; removes trace function declarations
tests/test_general.cpp Adds 956 lines of comprehensive realloc tests; removes trace tests; reduces test memory/iterations
tests/test_api_exhaustive.cpp Adds realloc edge case tests with realloc operations in random walk tests
tests/internal.hpp Adds reallocate() wrapper method
tests/CMakeLists.txt Fixes paths from CMAKE_SOURCE_DIR to CMAKE_CURRENT_SOURCE_DIR; removes trace test
tests/.clang-tidy Disables -use-ranges and -signed-bitwise warnings
perftest/main.c Refactors to compare o1heap vs malloc using abstraction layer
perftest/README.md Adds benchmark results showing o1heap's performance advantages
README.md Updates performance numbers; documents realloc addition; removes trace documentation
CMakeLists.txt Adds top-level CMake file for project
AGENTS.md, CLAUDE.md Adds AI agent instructions
.github/workflows/main.yml Updates cmake to build from root directory
Files not reviewed (1)
  • .idea/dictionaries/project.xml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@pavel-kirienko pavel-kirienko merged commit c5fb77e into master Jan 21, 2026
9 checks passed
@pavel-kirienko pavel-kirienko deleted the dev branch January 21, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add o1HeapReallocate

2 participants