diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2019-05-15 14:00:56 -0700 |
---|---|---|
committer | Joshua Haberman <jhaberman@gmail.com> | 2019-05-15 14:00:56 -0700 |
commit | 4d89a44b2626ca52998344b95f6f86ea068c4e56 (patch) | |
tree | caeff10d42a7ced0f6f7a474db122251131d9e3d /README.md | |
parent | ae107c7ab983f22791897569ec7b8356e76d72fb (diff) |
Some revisions to README.md and DESIGN.md.
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 15 |
1 files changed, 5 insertions, 10 deletions
@@ -10,16 +10,16 @@ upb generates a C API for creating, parsing, and serializing messages as declared in `.proto` files. upb is heavily arena-based -- all -messages always live in an arena. You control where the arena gets -memory from, so the arena can come from stack memory, for example. -Here is a simple example (`ConformanceRequest` and `ConformanceResponse` -are generated message types): +messages always live in an arena (note: the arena can live in stack or +static memory if desired). Here is a simple example: ```c #include "conformance/conformance.upb.h" void foo(const char* data, size_t size) { upb_arena *arena; + + /* Generated message type. */ conformance_ConformanceRequest *request; conformance_ConformanceResponse *response; @@ -46,16 +46,11 @@ void foo(const char* data, size_t size) { } } + /* Frees all messages on the arena. */ upb_arena_free(arena); } ``` -Messages are opaque, so you always have to use generated getter/setter -methods to read/write fields. This is somewhat unfortunate for C -because the function names are long, but this is necessary to provide -correct semantics for oneof fields, proto2 presence, etc. It is also -necessary for providing a stable ABI, in cases where that is desired. - API and ABI are both subject to change! Please do not distribute as a shared library for this reason (for now at least). |