File indexing completed on 2025-01-18 10:13:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef UPB_MEM_ARENA_H_
0021 #define UPB_MEM_ARENA_H_
0022
0023 #include <stddef.h>
0024 #include <stdint.h>
0025
0026 #include "upb/mem/alloc.h"
0027 #include "upb/mem/internal/arena.h"
0028
0029
0030 #include "upb/port/def.inc"
0031
0032 typedef struct upb_Arena upb_Arena;
0033
0034 #ifdef __cplusplus
0035 extern "C" {
0036 #endif
0037
0038
0039
0040
0041 UPB_API upb_Arena* upb_Arena_Init(void* mem, size_t n, upb_alloc* alloc);
0042
0043 UPB_API void upb_Arena_Free(upb_Arena* a);
0044 UPB_API bool upb_Arena_Fuse(upb_Arena* a, upb_Arena* b);
0045
0046 bool upb_Arena_IncRefFor(upb_Arena* a, const void* owner);
0047 void upb_Arena_DecRefFor(upb_Arena* a, const void* owner);
0048
0049 size_t upb_Arena_SpaceAllocated(upb_Arena* a, size_t* fused_count);
0050 uint32_t upb_Arena_DebugRefCount(upb_Arena* a);
0051
0052 UPB_API_INLINE upb_Arena* upb_Arena_New(void) {
0053 return upb_Arena_Init(NULL, 0, &upb_alloc_global);
0054 }
0055
0056 UPB_API_INLINE void* upb_Arena_Malloc(struct upb_Arena* a, size_t size);
0057
0058 UPB_API_INLINE void* upb_Arena_Realloc(upb_Arena* a, void* ptr, size_t oldsize,
0059 size_t size);
0060
0061
0062
0063
0064
0065
0066
0067
0068 void upb_Arena_SetMaxBlockSize(size_t max);
0069
0070
0071
0072
0073
0074 UPB_API_INLINE void upb_Arena_ShrinkLast(upb_Arena* a, void* ptr,
0075 size_t oldsize, size_t size);
0076
0077 #ifdef UPB_TRACING_ENABLED
0078 void upb_Arena_SetTraceHandler(void (*initArenaTraceHandler)(const upb_Arena*,
0079 size_t size),
0080 void (*fuseArenaTraceHandler)(const upb_Arena*,
0081 const upb_Arena*),
0082 void (*freeArenaTraceHandler)(const upb_Arena*));
0083 #endif
0084
0085 #ifdef __cplusplus
0086 }
0087 #endif
0088
0089 #include "upb/port/undef.inc"
0090
0091 #endif