• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2023 Google LLC.  All rights reserved.
3 //
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file or at
6 // https://developers.google.com/open-source/licenses/bsd
7 
8 #include "upb/mem/alloc.h"
9 
10 #include <stdlib.h>
11 
12 // Must be last.
13 #include "upb/port/def.inc"
14 
upb_global_allocfunc(upb_alloc * alloc,void * ptr,size_t oldsize,size_t size)15 static void* upb_global_allocfunc(upb_alloc* alloc, void* ptr, size_t oldsize,
16                                   size_t size) {
17   UPB_UNUSED(alloc);
18   UPB_UNUSED(oldsize);
19   if (size == 0) {
20     free(ptr);
21     return NULL;
22   } else {
23     return realloc(ptr, size);
24   }
25 }
26 
27 upb_alloc upb_alloc_global = {&upb_global_allocfunc};
28