[v2] Add memory resource to owned and borrowed objects#419
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## anilm3/v2-use-allocators-internally #419 +/- ##
=======================================================================
- Coverage 85.88% 85.57% -0.31%
=======================================================================
Files 176 177 +1
Lines 9054 9138 +84
Branches 3853 3940 +87
=======================================================================
+ Hits 7776 7820 +44
+ Misses 498 497 -1
- Partials 780 821 +41
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Benchmarks clangBenchmark execution time: 2025-06-20 23:06:34 Comparing candidate commit 907ed81 in PR branch Found 0 performance improvements and 1 performance regressions! Performance is the same for 0 metrics, 0 unstable metrics. scenario:global-benchmark.random.clang
|
Benchmarks clang-pgoBenchmark execution time: 2025-06-20 23:22:01 Comparing candidate commit 907ed81 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics. |
Benchmarks gccBenchmark execution time: 2025-06-20 23:08:10 Comparing candidate commit 907ed81 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics. |
Artifact Size Comparison 📦
|
There was a problem hiding this comment.
Pull Request Overview
This PR refactors test code to consistently use the new object_builder API for map and array creation, ensures allocator compatibility in owned_object, and adds allocator-behavior tests in object_test.cpp.
- Replaces
owned_object::make_map,make_array, and rawnullptrconstructors withobject_builder::map,object_builder::array, andowned_object::make_null()across the test suite. - Updates integer literal suffixes (
1UL→1U) for initializer-list overloads. - Introduces
memory_resourcetests intests/unit/object_test.cppto verify allocation and deallocation behavior and allocator incompatibility.
Reviewed Changes
Copilot reviewed 40 out of 40 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/waf_test.cpp | Switched map creation to object_builder::map |
| tests/unit/value_iterator_test.cpp | Replaced array/map creation with object_builder variants |
| tests/unit/rule_test.cpp | Updated root object creation to object_builder::map |
| tests/unit/processor/structured_processor*.cpp | Adjusted map/array builders and changed 1UL to 1U |
| tests/unit/processor/processor_test.cpp | Switched map initializations to object_builder::map |
| tests/unit/processor/jwt_decode_test.cpp | Replaced owned_object::make_map/array with object_builder calls |
| tests/unit/processor/fingerprint_test.cpp | Updated map/array builders |
| tests/unit/object_view_test.cpp | Switched to object_builder::map/array for nested object setup |
| tests/unit/object_test.cpp | Added memory_resource tests, included allocator tests |
| tests/unit/module_test.cpp | Replaced make_map calls with object_builder::map |
| tests/unit/kv_iterator_test.cpp | Swapped to object_builder::array/map |
| tests/unit/key_iterator_test.cpp | Updated array/map initializations to object_builder |
| tests/unit/expression_test.cpp | Used object_builder::map for all root objects |
| tests/unit/exclusion/**/*.cpp | Replaced all owned_object::make_map with object_builder::map |
dd9fed2 to
154cbfe
Compare
This PR expands #418 to use allocators on owned and borrowed objects, ensuring that objects are allocator-compatible and that all possible allocations are performed with the correct allocator.
All relevant changes are in
object.hpp.Note that the size of the PR is due to ancillary changes required due to the following changes to the owned object:
nullptr_tconstructor forowned_objecthas been removed as it was causing conflicts with other constructors.make_(array|map)functions accepting initializer lists have been extracted out intoobject_builder::(map|array)as they were also causing conflicts due to the introduction of the capacity parameter to the other overloads.These changes can be safely ignored.
Remaining work (Next PRs):
Update objects to use allocators more effectively.Check for allocator compatibility where relevant.context_init.ddwaf_objectfunctions.