# Test the AllTypes encoding & decoding using callbacks for all fields.
-Import("env")
+Import("env", "malloc_env")
c = Copy("$TARGET", "$SOURCE")
env.Command("alltypes.proto", "#alltypes/alltypes.proto", c)
env.RunTest("optionals.refdecout", [refdec, "optionals.output"], ARGS = ['1'])
env.RunTest("optionals.decout", [dec, "optionals.output"], ARGS = ['1'])
+# Try with malloc support also
+mallocbin = malloc_env.Object("decode_with_malloc.o", "decode_alltypes_callback.c")
+mallocdec = malloc_env.Program("decode_with_malloc", [mallocbin, "alltypes.pb.o", "$COMMON/pb_decode_with_malloc.o", "$COMMON/pb_common_with_malloc.o", "$COMMON/malloc_wrappers.o"])
+env.RunTest("decode_with_malloc.output", [mallocdec, "encode_alltypes_callback.output"])
alltypes.oneof_msg1.arg = &oneof_msg1;
}
- return pb_decode(stream, AllTypes_fields, &alltypes);
+ bool status = pb_decode(stream, AllTypes_fields, &alltypes);
+
+#ifdef PB_ENABLE_MALLOC
+ /* Just to check for any interference between pb_release() and callback fields */
+ pb_release(AllTypes_fields, &alltypes);
+#endif
+
+ return status;
}
int main(int argc, char **argv)