We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
solve
diff --git a/src/handlebars_string.c b/src/handlebars_string.c index 317125a..7e46d2b 100644 --- a/src/handlebars_string.c +++ b/src/handlebars_string.c @@ -170,20 +170,24 @@ void handlebars_string_delref(struct handlebars_string * string) void handlebars_string_addref_ex(struct handlebars_string * string, const char * expr, const char * loc) { +#ifndef HANDLEBARS_NO_REFCOUNT if (getenv("HANDLEBARS_RC_DEBUG")) { // LCOV_EXCL_START size_t rc = handlebars_rc_refcount(&string->rc); fprintf(stderr, "STR ADDREF %p (%zu -> %zu) %s %s\n", string, rc, rc + 1, expr, loc); } // LCOV_EXCL_STOP handlebars_string_addref(string); +#endif } void handlebars_string_delref_ex(struct handlebars_string * string, const char * expr, const char * loc) { +#ifndef HANDLEBARS_NO_REFCOUNT if (getenv("HANDLEBARS_RC_DEBUG")) { // LCOV_EXCL_START size_t rc = handlebars_rc_refcount(&string->rc); fprintf(stderr, "STR DELREF %p (%zu -> %zu) %s %s\n", string, rc, rc - 1, expr, loc); } // LCOV_EXCL_STOP handlebars_string_delref(string); +#endif } #ifdef HANDLEBARS_ENABLE_DEBUG @@ -211,7 +215,9 @@ static inline struct handlebars_string * separate_string(struct handlebars_strin void handlebars_string_immortalize(struct handlebars_string * string) { +#ifndef HANDLEBARS_NO_REFCOUNT string->rc.refcount = UINT8_MAX; +#endif } // }}} Reference Counting @@ -750,9 +756,11 @@ struct handlebars_string * handlebars_string_indent( const struct handlebars_string * indent_str ) { struct handlebars_string * new_string = handlebars_string_init(context, string->len); +#ifndef HANDLEBARS_NO_REFCOUNT if (handlebars_rc_refcount(&string->rc) > 0) { handlebars_string_addref(new_string); } +#endif return handlebars_string_indent_append(context, new_string, string, indent_str); } diff --git a/src/handlebars_map.c b/src/handlebars_map.c index d20ae06..50f0c8c 100644 --- a/src/handlebars_map.c +++ b/src/handlebars_map.c @@ -291,20 +291,24 @@ void handlebars_map_delref(struct handlebars_map * map) void handlebars_map_addref_ex(struct handlebars_map * map, const char * expr, const char * loc) { +#ifndef HANDLEBARS_NO_REFCOUNT if (getenv("HANDLEBARS_RC_DEBUG")) { // LCOV_EXCL_START size_t rc = handlebars_rc_refcount(&map->rc); fprintf(stderr, "MAP ADDREF %p (%zu -> %zu) %s %s\n", map, rc, rc + 1, expr, loc); } // LCOV_EXCL_STOP handlebars_map_addref(map); +#endif } void handlebars_map_delref_ex(struct handlebars_map * map, const char * expr, const char * loc) { +#ifndef HANDLEBARS_NO_REFCOUNT if (getenv("HANDLEBARS_RC_DEBUG")) { // LCOV_EXCL_START size_t rc = handlebars_rc_refcount(&map->rc); fprintf(stderr, "MAP DELREF %p (%zu -> %zu) %s %s\n", map, rc, rc - 1, expr, loc); } // LCOV_EXCL_STOP handlebars_map_delref(map); +#endif } #ifdef HANDLEBARS_ENABLE_DEBUG @@ -523,9 +527,11 @@ struct handlebars_map * handlebars_map_rehash(struct handlebars_map * map, bool size_t vec_capacity = 1 << map_choose_vec_capacity_log2(map->i + 1); struct handlebars_map * prev_map = map; map = handlebars_map_copy_ctor(prev_map, vec_capacity); +#ifndef HANDLEBARS_NO_REFCOUNT if (handlebars_rc_refcount(&prev_map->rc) >= 1) { // ugh handlebars_map_addref(map); } +#endif handlebars_map_delref(prev_map); } diff --git a/src/handlebars_value_handlers.c b/src/handlebars_value_handlers.c index ee89a1e..8636f37 100644 --- a/src/handlebars_value_handlers.c +++ b/src/handlebars_value_handlers.c @@ -63,20 +63,24 @@ void handlebars_user_delref(struct handlebars_user * user) void handlebars_user_addref_ex(struct handlebars_user * user, const char * expr, const char * loc) { +#ifndef HANDLEBARS_NO_REFCOUNT if (getenv("HANDLEBARS_RC_DEBUG")) { // LCOV_EXCL_START size_t rc = handlebars_rc_refcount(&user->rc); fprintf(stderr, "USR ADDREF %p (%zu -> %zu) %s %s\n", user, rc, rc + 1, expr, loc); } // LCOV_EXCL_STOP handlebars_user_addref(user); +#endif } void handlebars_user_delref_ex(struct handlebars_user * user, const char * expr, const char * loc) { +#ifndef HANDLEBARS_NO_REFCOUNT if (getenv("HANDLEBARS_RC_DEBUG")) { // LCOV_EXCL_START size_t rc = handlebars_rc_refcount(&user->rc); fprintf(stderr, "USR DELREF %p (%zu -> %zu) %s %s\n", user, rc, rc - 1, expr, loc); } // LCOV_EXCL_STOP handlebars_user_delref(user); +#endif } #ifdef HANDLEBARS_ENABLE_DEBUG diff --git a/src/handlebars_closure.c b/src/handlebars_closure.c index 4b9daa4..ab8b0a8 100644 --- a/src/handlebars_closure.c +++ b/src/handlebars_closure.c @@ -86,7 +86,9 @@ struct handlebars_closure * handlebars_closure_ctor( ) { struct handlebars_closure * closure = handlebars_talloc_zero_size(vm, sizeof(struct handlebars_closure) + (sizeof(struct handlebars_value) * localc)); talloc_set_type(closure, struct handlebars_closure); +#ifndef HANDLEBARS_NO_REFCOUNT handlebars_rc_init(&closure->rc); +#endif closure->vm = vm; closure->fn = fn; closure->localc = localc; diff --git a/src/handlebars_ptr.c b/src/handlebars_ptr.c index c37ce8e..f3ce723 100644 --- a/src/handlebars_ptr.c +++ b/src/handlebars_ptr.c @@ -36,7 +36,9 @@ struct handlebars_ptr { +#ifndef HANDLEBARS_NO_REFCOUNT struct handlebars_rc rc; +#endif const char * typ; void * uptr; bool nofree; @@ -75,7 +77,9 @@ struct handlebars_ptr * handlebars_ptr_ctor_ex( ) { struct handlebars_ptr * ptr = handlebars_talloc(ctx, struct handlebars_ptr); HANDLEBARS_MEMCHECK(ptr, ctx); +#ifndef HANDLEBARS_NO_REFCOUNT handlebars_rc_init(&ptr->rc); +#endif ptr->typ = typ; ptr->nofree = nofree; ptr->uptr = uptr;
The text was updated successfully, but these errors were encountered:
01349d6
No branches or pull requests
solve
The text was updated successfully, but these errors were encountered: