Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VVCSoftware_VTM
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jvet-tuc
VVCSoftware_VTM
Commits
2eb8cc48
Commit
2eb8cc48
authored
2 years ago
by
Frank Bossen
Browse files
Options
Downloads
Patches
Plain Diff
Adjust size of be a multiple of alignment when using std::aligned_alloc
Fixed an issue introduced in !2509
parent
839ad6db
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/Lib/CommonLib/CommonDef.h
+7
-1
7 additions, 1 deletion
source/Lib/CommonLib/CommonDef.h
with
7 additions
and
1 deletion
source/Lib/CommonLib/CommonDef.h
+
7
−
1
View file @
2eb8cc48
...
...
@@ -652,7 +652,13 @@ constexpr size_t MALLOC_ALIGN_SIZE = MEMORY_ALIGN_DEF_SIZE;
#define xMalloc(type, len) _aligned_malloc(sizeof(type) * (len), MEMORY_ALIGN_DEF_SIZE)
#define xFree(ptr) _aligned_free(ptr)
#else
#define xMalloc(type, len) std::aligned_alloc(MALLOC_ALIGN_SIZE, sizeof(type) * (len))
template
<
typename
T
>
inline
void
*
alignedAllocAdjustSize
(
size_t
len
)
{
// std::aligned_alloc requires that the size parameter is an integral multiple of the alignment
const
size_t
numBytes
=
(
sizeof
(
T
)
*
len
+
MALLOC_ALIGN_SIZE
-
1
)
&
~
(
MALLOC_ALIGN_SIZE
-
1
);
return
std
::
aligned_alloc
(
MALLOC_ALIGN_SIZE
,
numBytes
);
}
#define xMalloc(type, len) alignedAllocAdjustSize<type>(len)
#define xFree(ptr) std::free(ptr)
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment