mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-24 04:15:11 +00:00
util-memory: Expose aligned_offset to code
This commit is contained in:
parent
67099c2b23
commit
adafbf40ca
2 changed files with 5 additions and 6 deletions
|
@ -20,10 +20,6 @@
|
|||
#include "util-memory.h"
|
||||
#include <cstdlib>
|
||||
|
||||
inline size_t aligned_offset(size_t align, size_t size) {
|
||||
return ((size / align) + 1) * align;
|
||||
}
|
||||
|
||||
void* util::malloc_aligned(size_t align, size_t size) {
|
||||
// Ensure that we have space for the pointer and the data.
|
||||
size_t asize = aligned_offset(align, size + sizeof(void*));
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
#include <malloc.h>
|
||||
|
||||
namespace util {
|
||||
inline size_t aligned_offset(size_t align, size_t pos) {
|
||||
return ((pos / align) + 1) * align;
|
||||
}
|
||||
void* malloc_aligned(size_t align, size_t size);
|
||||
void free_aligned(void* mem);
|
||||
|
||||
|
@ -55,11 +58,11 @@ namespace util {
|
|||
}
|
||||
|
||||
inline pointer allocate(size_type n) {
|
||||
return (pointer)_aligned_malloc(n*sizeof(value_type), N);
|
||||
return (pointer)malloc_aligned(n*sizeof(value_type), N);
|
||||
}
|
||||
|
||||
inline void deallocate(pointer p, size_type) {
|
||||
_aligned_free(p);
|
||||
free_aligned(p);
|
||||
}
|
||||
|
||||
inline void construct(pointer p, const value_type & wert) {
|
||||
|
|
Loading…
Reference in a new issue