From 4d89a44b2626ca52998344b95f6f86ea068c4e56 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Wed, 15 May 2019 14:00:56 -0700 Subject: Some revisions to README.md and DESIGN.md. --- README.md | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 6edb245..feaa4d5 100644 --- a/README.md +++ b/README.md @@ -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). -- cgit v1.2.3