upb_internal.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2021, Google LLC
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of Google LLC nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
20  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef UPB_INT_H_
29 #define UPB_INT_H_
30 
31 #include "upb/upb.h"
32 
33 struct mem_block;
34 typedef struct mem_block mem_block;
35 
36 struct upb_Arena {
38  /* Stores cleanup metadata for this arena.
39  * - a pointer to the current cleanup counter.
40  * - a boolean indicating if there is an unowned initial block. */
42 
43  /* Allocator to allocate arena blocks. We are responsible for freeing these
44  * when we are destroyed. */
47 
48  /* When multiple arenas are fused together, each arena points to a parent
49  * arena (root points to itself). The root tracks how many live arenas
50  * reference it. */
51  uint32_t refcount; /* Only used when a->parent == a */
52  struct upb_Arena* parent;
53 
54  /* Linked list of blocks to free/cleanup. */
56 };
57 
58 // Encodes a float or double that is round-trippable, but as short as possible.
59 // These routines are not fully optimal (not guaranteed to be shortest), but are
60 // short-ish and match the implementation that has been used in protobuf since
61 // the beginning.
62 //
63 // The given buffer size must be at least kUpb_RoundTripBufferSize.
65 void _upb_EncodeRoundTripDouble(double val, char* buf, size_t size);
66 void _upb_EncodeRoundTripFloat(float val, char* buf, size_t size);
67 
68 #endif /* UPB_INT_H_ */
_upb_EncodeRoundTripFloat
void _upb_EncodeRoundTripFloat(float val, char *buf, size_t size)
Definition: upb/upb/upb.c:354
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
upb_Arena::freelist
mem_block * freelist
Definition: upb_internal.h:55
upb_Arena::parent
struct upb_Arena * parent
Definition: upb_internal.h:52
upb.h
upb_Arena::last_size
uint32_t last_size
Definition: upb_internal.h:46
mem_block
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2272
uintptr_t
_W64 unsigned int uintptr_t
Definition: stdint-msvc2008.h:119
upb_Arena::cleanup_metadata
uintptr_t cleanup_metadata
Definition: upb_internal.h:41
upb_Arena::block_alloc
upb_alloc * block_alloc
Definition: upb_internal.h:45
upb_Arena::refcount
uint32_t refcount
Definition: upb_internal.h:51
_upb_EncodeRoundTripDouble
void _upb_EncodeRoundTripDouble(double val, char *buf, size_t size)
Definition: upb/upb/upb.c:344
upb_Arena::head
_upb_ArenaHead head
Definition: upb_internal.h:37
kUpb_RoundTripBufferSize
@ kUpb_RoundTripBufferSize
Definition: upb_internal.h:64
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
upb_alloc
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:299
upb_Arena
Definition: upb_internal.h:36
_upb_ArenaHead
Definition: upb/upb/upb.h:174
upb_Arena::freelist_tail
mem_block * freelist_tail
Definition: upb_internal.h:55


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:47