delete upb_Arena_Alloc()

PiperOrigin-RevId: 491682231
pull/13171/head
Eric Salo 2 years ago committed by Copybara-Service
parent bc15a2877a
commit e70b102387
  1. 8
      upb/mem/arena.c
  2. 14
      upb/mem/arena.h

@ -123,12 +123,6 @@ void* _upb_Arena_SlowMalloc(upb_Arena* a, size_t size) {
return upb_Arena_Malloc(a, size);
}
static void* upb_Arena_doalloc(upb_alloc* alloc, void* ptr, size_t oldsize,
size_t size) {
upb_Arena* a = (upb_Arena*)alloc; /* upb_alloc is initial member. */
return upb_Arena_Realloc(a, ptr, oldsize, size);
}
/* Public Arena API ***********************************************************/
static upb_Arena* arena_initslow(void* mem, size_t n, upb_alloc* alloc) {
@ -144,7 +138,6 @@ static upb_Arena* arena_initslow(void* mem, size_t n, upb_alloc* alloc) {
a = UPB_PTR_AT(mem, n - sizeof(*a), upb_Arena);
n -= sizeof(*a);
a->head.alloc.func = &upb_Arena_doalloc;
a->block_alloc = alloc;
a->parent = a;
a->refcount = 1;
@ -178,7 +171,6 @@ upb_Arena* upb_Arena_Init(void* mem, size_t n, upb_alloc* alloc) {
a = UPB_PTR_AT(mem, n - sizeof(*a), upb_Arena);
a->head.alloc.func = &upb_Arena_doalloc;
a->block_alloc = alloc;
a->parent = a;
a->refcount = 1;

@ -52,11 +52,6 @@ typedef struct upb_Arena upb_Arena;
typedef void upb_CleanupFunc(void* context);
typedef struct {
/* We implement the allocator interface.
* This must be the first member of upb_Arena!
* TODO(haberman): remove once handlers are gone. */
upb_alloc alloc;
char *ptr, *end;
} _upb_ArenaHead;
@ -64,10 +59,11 @@ typedef struct {
extern "C" {
#endif
/* Creates an arena from the given initial block (if any -- n may be 0).
* Additional blocks will be allocated from |alloc|. If |alloc| is NULL, this
* is a fixed-size arena and cannot grow. */
// Creates an arena from the given initial block (if any -- n may be 0).
// Additional blocks will be allocated from |alloc|. If |alloc| is NULL, this
// is a fixed-size arena and cannot grow.
upb_Arena* upb_Arena_Init(void* mem, size_t n, upb_alloc* alloc);
void upb_Arena_Free(upb_Arena* a);
bool upb_Arena_AddCleanup(upb_Arena* a, void* ud, upb_CleanupFunc* func);
bool upb_Arena_Fuse(upb_Arena* a, upb_Arena* b);
@ -75,8 +71,6 @@ void* _upb_Arena_SlowMalloc(upb_Arena* a, size_t size);
size_t upb_Arena_SpaceAllocated(upb_Arena* arena);
uint32_t upb_Arena_DebugRefCount(upb_Arena* arena);
UPB_INLINE upb_alloc* upb_Arena_Alloc(upb_Arena* a) { return (upb_alloc*)a; }
UPB_INLINE size_t _upb_ArenaHas(upb_Arena* a) {
_upb_ArenaHead* h = (_upb_ArenaHead*)a;
return (size_t)(h->end - h->ptr);

Loading…
Cancel
Save