arena.c
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 #include <Zend/zend_API.h>
32 
33 #include "php-upb.h"
34 
35 // -----------------------------------------------------------------------------
36 // Arena
37 // -----------------------------------------------------------------------------
38 
39 typedef struct Arena {
40  zend_object std;
42 } Arena;
43 
44 zend_class_entry *Arena_class_entry;
45 static zend_object_handlers Arena_object_handlers;
46 
47 // PHP Object Handlers /////////////////////////////////////////////////////////
48 
49 static zend_object* Arena_Create(zend_class_entry *class_type) {
50  Arena *intern = emalloc(sizeof(Arena));
51  zend_object_std_init(&intern->std, class_type);
52  intern->std.handlers = &Arena_object_handlers;
53  intern->arena = upb_arena_new();
54  // Skip object_properties_init(), we don't allow derived classes.
55  return &intern->std;
56 }
57 
58 static void Arena_Free(zend_object* obj) {
59  Arena* intern = (Arena*)obj;
60  upb_arena_free(intern->arena);
61  zend_object_std_dtor(&intern->std);
62 }
63 
64 // C Functions from arena.h ////////////////////////////////////////////////////
65 
66 void Arena_Init(zval* val) {
68 }
69 
70 upb_arena *Arena_Get(zval *val) {
71  Arena *a = (Arena*)Z_OBJ_P(val);
72  return a->arena;
73 }
74 
75 // -----------------------------------------------------------------------------
76 // Module init.
77 // -----------------------------------------------------------------------------
78 
79 // No public methods.
80 static const zend_function_entry Arena_methods[] = {
81  ZEND_FE_END
82 };
83 
85  zend_class_entry tmp_ce;
86 
87  INIT_CLASS_ENTRY(tmp_ce, "Google\\Protobuf\\Internal\\Arena", Arena_methods);
88  Arena_class_entry = zend_register_internal_class(&tmp_ce);
89  Arena_class_entry->create_object = Arena_Create;
90  Arena_class_entry->ce_flags |= ZEND_ACC_FINAL;
91 
92  memcpy(&Arena_object_handlers, &std_object_handlers,
93  sizeof(zend_object_handlers));
95 }
obj
OPENSSL_EXPORT const ASN1_OBJECT * obj
Definition: x509.h:1671
upb_arena
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2252
Arena
struct Arena Arena
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/arena.h:189
Arena_class_entry
zend_class_entry * Arena_class_entry
Definition: arena.c:44
upb_arena_free
void upb_arena_free(upb_arena *a)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:2391
Arena
Definition: arena.c:39
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
ZVAL_OBJ
#define ZVAL_OBJ(zval_ptr, call_create)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:238
Arena::std
zend_object std
Definition: arena.c:40
Arena_ModuleInit
void Arena_ModuleInit()
Definition: arena.c:84
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
Arena_Init
void Arena_Init(zval *val)
Definition: arena.c:66
Arena_Get
upb_arena * Arena_Get(zval *val)
Definition: arena.c:70
Z_OBJ_P
#define Z_OBJ_P(zval_p)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1497
upb_arena_new
UPB_INLINE upb_arena * upb_arena_new(void)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:392
Arena_methods
static const zend_function_entry Arena_methods[]
Definition: arena.c:80
intern
upb_strtable_uninit & intern
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/map.c:222
Arena_object_handlers
static zend_object_handlers Arena_object_handlers
Definition: arena.c:45
php-upb.h
Arena_Free
static void Arena_Free(zend_object *obj)
Definition: arena.c:58
Arena_Create
static zend_object * Arena_Create(zend_class_entry *class_type)
Definition: arena.c:49
Arena::arena
upb_arena * arena
Definition: arena.c:41


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:42