Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nanopb/nanopb.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/pb.h
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-03-17 19:25:58 +0400
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-03-17 19:25:58 +0400
commit607cb998b5472ef1df461995b33694e9a54bef23 (patch)
treeef84373e7cbff3b93bfe3163f90c8c721d8c1694 /pb.h
parentab62402059ff3752660ffc9f292cf210aef59be0 (diff)
More configuration options for dynamic alloc
Diffstat (limited to 'pb.h')
-rw-r--r--pb.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/pb.h b/pb.h
index d6cb1d4..6f84385 100644
--- a/pb.h
+++ b/pb.h
@@ -10,6 +10,9 @@
* uncommenting the lines, or on the compiler command line. *
*****************************************************************/
+/* Enable support for dynamically allocated fields */
+/* #define PB_ENABLE_MALLOC 1 */
+
/* Define this if your CPU architecture is big endian, i.e. it
* stores the most-significant byte first. */
/* #define __BIG_ENDIAN__ 1 */
@@ -340,6 +343,17 @@ struct _pb_extension_t {
pb_extension_t *next;
};
+/* Memory allocation functions to use. You can define pb_realloc and
+ * pb_free to custom functions if you want. */
+#ifdef PB_ENABLE_MALLOC
+# ifndef pb_realloc
+# define pb_realloc(ptr, size) realloc(ptr, size)
+# endif
+# ifndef pb_free
+# define pb_free(ptr) free(ptr)
+# endif
+#endif
+
/* These macros are used to declare pb_field_t's in the constant array. */
/* Size of a structure member, in bytes. */
#define pb_membersize(st, m) (sizeof ((st*)0)->m)