diff --git a/configure.ac b/configure.ac index 79f1db7..0fe16c0 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_INIT(src/google/protobuf-c/protobuf-c.h) -PROTOBUF_C_VERSION=0.9 +PROTOBUF_C_VERSION=0.10-beta0 AM_INIT_AUTOMAKE(protobuf-c, $PROTOBUF_C_VERSION) PACKAGE=protobuf-c @@ -21,7 +21,7 @@ you must add '-Iincludedir' to CXXFLAGS and '-Llibdir' to LDFLAGS. ])]) pbc_savelibs="$LIBS" -LIBS="$LIBS -lprotoc" +LIBS="$LIBS -lprotoc -lprotobuf" AC_TRY_LINK([#include ], [google::protobuf::compiler::CommandLineInterface cli;], [], diff --git a/src/google/protobuf-c/protobuf-c.h b/src/google/protobuf-c/protobuf-c.h index c5fe834..ab2e51c 100644 --- a/src/google/protobuf-c/protobuf-c.h +++ b/src/google/protobuf-c/protobuf-c.h @@ -255,8 +255,9 @@ struct _ProtobufCMessageDescriptor * In particular, ProtobufCMessage doesn't have * any allocation policy associated with it. * That's because it is common to create ProtobufCMessage's - * on the stack. In fact, we recommend that if you are - * sending messages. + * on the stack. In fact, we that's what we recommend + * for sending messages (because if you just allocate from the + * stack, then you can't really have a memory leak). * * This means that functions like protobuf_c_message_unpack() * which return a ProtobufCMessage must be paired @@ -276,6 +277,14 @@ struct _ProtobufCMessage }; #define PROTOBUF_C_MESSAGE_INIT(descriptor) { descriptor, 0, NULL } +/* To pack a message: you have two options: + (1) you can compute the size of the message + using protobuf_c_message_get_packed_size() + then pass protobuf_c_message_pack() a buffer of + that length. + (2) Provide a virtual buffer (a ProtobufCBuffer) to + accept data as we scan through it. + */ size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message); size_t protobuf_c_message_pack (const ProtobufCMessage *message, uint8_t *out); @@ -398,8 +407,6 @@ struct _ProtobufCBufferSimple /* ====== private ====== */ #include "protobuf-c-private.h" -/* TODO: crib from glib */ -#define PROTOBUF_C_GNUC_PRINTF(format_argno, ellipsis_argno) PROTOBUF_C_END_DECLS diff --git a/src/test/test-full.proto b/src/test/test-full.proto index c3ff845..0244cd3 100644 --- a/src/test/test-full.proto +++ b/src/test/test-full.proto @@ -8,6 +8,10 @@ enum TestEnumSmall { VALUE = 0; OTHER_VALUE = 1; } + +// these number are specifically chosen to test the +// boundaries of when an enum requires a certain number of bytes. +// e.g. 16383 requires 3 bytes; 16383 requires 4. enum TestEnum { VALUE0 = 0; VALUE1 = 1;