UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
M4Memory.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "vdecmpeg4.h"
5#include "M4Global.h"
6#include "M4MemOps.h"
7
8namespace vdecmpeg4
9{
10
14#define M4_MEMORY_HANDLER \
15public: \
16 void* operator new(size_t) \
17 { \
18 M4CHECK(false && "new not allowed"); \
19 return (void*)1; \
20 } \
21 void operator delete[](void*) \
22 { \
23 M4CHECK(false && "delete[] not allowed"); \
24 } \
25 void* operator new[](size_t) \
26 { \
27 M4CHECK(false && "new[] not allowed"); \
28 return (void*)1; \
29 }
30
31
32
34{
35public:
38 {
39 mAllocCB = cbMem;
40 mFreeCB = cbFree;
41 }
42
44 void* malloc(size_t size, size_t alignment = 32)
45 {
46 M4CHECK(mAllocCB);
47 void* ptr = (*mAllocCB)((uint32)size, (uint32)alignment);
48 return ptr;
49 }
50
52 void free(void* ptr)
53 {
54 M4CHECK(mFreeCB);
55 if (ptr)
56 {
57 (*mFreeCB)(ptr);
58 }
59 }
60
61private:
62 VIDAllocator mAllocCB;
63 VIDDeallocator mFreeCB;
64};
65
66
67}
68
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition M4Memory.h:34
void free(void *ptr)
Memory release.
Definition M4Memory.h:52
void * malloc(size_t size, size_t alignment=32)
Memory allocation with possible alignment.
Definition M4Memory.h:44
void init(VIDAllocator cbMem, VIDDeallocator cbFree)
Init global decoder instance memory system.
Definition M4Memory.h:37
Definition M4Bitstream.h:9
void *(* VIDAllocator)(uint32 size, uint32 alignment)
Definition vdecmpeg4_Platform.h:20
void(* VIDDeallocator)(void *block)
memory release callback
Definition vdecmpeg4_Platform.h:38
#define M4CHECK
Definition vdecmpeg4_Types.h:8