From a503b8859c37906ab5012db163daca43bfe393bb Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Sat, 21 May 2011 17:35:21 -0700 Subject: Make all handlers objects refcounted. I'm realizing that basically all upb objects will need to be refcounted to be sharable across languages, but *not* messages which are on their way out so we can get out of the business of data representations. Things which must be refcounted: - encoders, decoders - handlers objects - defs --- benchmarks/parsestream.upb_table.c | 8 ++++---- benchmarks/parsetostruct.upb_table.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'benchmarks') diff --git a/benchmarks/parsestream.upb_table.c b/benchmarks/parsestream.upb_table.c index 089d956..a4aebd8 100644 --- a/benchmarks/parsestream.upb_table.c +++ b/benchmarks/parsestream.upb_table.c @@ -10,7 +10,6 @@ static upb_string *input_str; static upb_msgdef *def; static upb_decoder decoder; static upb_stringsrc stringsrc; -upb_handlers handlers; static upb_sflow_t startsubmsg(void *_m, upb_value fval) { (void)_m; @@ -61,11 +60,12 @@ static bool initialize() return false; } - upb_handlers_init(&handlers); + upb_handlers *handlers = upb_handlers_new(); // Cause all messages to be read, but do nothing when they are. upb_handlerset hset = {NULL, NULL, value, startsubmsg, NULL, NULL, NULL}; - upb_handlers_reghandlerset(&handlers, def, &hset); - upb_decoder_init(&decoder, &handlers); + upb_handlers_reghandlerset(handlers, def, &hset); + upb_decoder_init(&decoder, handlers); + upb_handlers_unref(handlers); upb_stringsrc_init(&stringsrc); return true; } diff --git a/benchmarks/parsetostruct.upb_table.c b/benchmarks/parsetostruct.upb_table.c index 10d1481..f05395f 100644 --- a/benchmarks/parsetostruct.upb_table.c +++ b/benchmarks/parsetostruct.upb_table.c @@ -12,7 +12,6 @@ static upb_msgdef *def; static upb_msg *msg; static upb_stringsrc strsrc; static upb_decoder d; -static upb_handlers h; static bool initialize() { @@ -53,9 +52,10 @@ static bool initialize() msg = upb_msg_new(def); upb_stringsrc_init(&strsrc); - upb_handlers_init(&h); - upb_msg_reghandlers(&h, def); - upb_decoder_init(&d, &h); + upb_handlers *handlers = upb_handlers_new(); + upb_msg_reghandlers(handlers, def); + upb_decoder_init(&d, handlers); + upb_handlers_unref(handlers); if (!BYREF) { // Pretend the input string is stack-allocated, which will force its data -- cgit v1.2.3