Commit db96c69e authored by Andrey Grodzovsky's avatar Andrey Grodzovsky Committed by Alex Deucher
parent 8c737fcc
...@@ -71,6 +71,7 @@ void dc_sink_retain(const struct dc_sink *dc_sink) ...@@ -71,6 +71,7 @@ void dc_sink_retain(const struct dc_sink *dc_sink)
{ {
struct sink *sink = DC_SINK_TO_SINK(dc_sink); struct sink *sink = DC_SINK_TO_SINK(dc_sink);
ASSERT(sink->ref_count > 0);
++sink->ref_count; ++sink->ref_count;
} }
...@@ -78,6 +79,7 @@ void dc_sink_release(const struct dc_sink *dc_sink) ...@@ -78,6 +79,7 @@ void dc_sink_release(const struct dc_sink *dc_sink)
{ {
struct sink *sink = DC_SINK_TO_SINK(dc_sink); struct sink *sink = DC_SINK_TO_SINK(dc_sink);
ASSERT(sink->ref_count > 0);
--sink->ref_count; --sink->ref_count;
if (sink->ref_count == 0) { if (sink->ref_count == 0) {
...@@ -96,8 +98,7 @@ struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params) ...@@ -96,8 +98,7 @@ struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params)
if (false == construct(sink, init_params)) if (false == construct(sink, init_params))
goto construct_fail; goto construct_fail;
/* TODO should we move this outside to where the assignment actually happens? */ ++sink->ref_count;
dc_sink_retain(&sink->protected.public);
return &sink->protected.public; return &sink->protected.public;
......
...@@ -99,6 +99,8 @@ static void destruct(struct core_stream *stream) ...@@ -99,6 +99,8 @@ static void destruct(struct core_stream *stream)
void dc_stream_retain(const struct dc_stream *dc_stream) void dc_stream_retain(const struct dc_stream *dc_stream)
{ {
struct stream *stream = DC_STREAM_TO_STREAM(dc_stream); struct stream *stream = DC_STREAM_TO_STREAM(dc_stream);
ASSERT(stream->ref_count > 0);
stream->ref_count++; stream->ref_count++;
} }
...@@ -108,6 +110,7 @@ void dc_stream_release(const struct dc_stream *public) ...@@ -108,6 +110,7 @@ void dc_stream_release(const struct dc_stream *public)
struct core_stream *protected = DC_STREAM_TO_CORE(public); struct core_stream *protected = DC_STREAM_TO_CORE(public);
if (public != NULL) { if (public != NULL) {
ASSERT(stream->ref_count > 0);
stream->ref_count--; stream->ref_count--;
if (stream->ref_count == 0) { if (stream->ref_count == 0) {
...@@ -134,7 +137,7 @@ struct dc_stream *dc_create_stream_for_sink( ...@@ -134,7 +137,7 @@ struct dc_stream *dc_create_stream_for_sink(
if (false == construct(&stream->protected, dc_sink)) if (false == construct(&stream->protected, dc_sink))
goto construct_fail; goto construct_fail;
dc_stream_retain(&stream->protected.public); stream->ref_count++;
return &stream->protected.public; return &stream->protected.public;
......
...@@ -105,7 +105,7 @@ struct dc_surface *dc_create_surface(const struct dc *dc) ...@@ -105,7 +105,7 @@ struct dc_surface *dc_create_surface(const struct dc *dc)
if (false == construct(core_dc->ctx, surface)) if (false == construct(core_dc->ctx, surface))
goto construct_fail; goto construct_fail;
dc_surface_retain(&surface->protected.public); ++surface->ref_count;
return &surface->protected.public; return &surface->protected.public;
...@@ -162,6 +162,7 @@ void dc_surface_retain(const struct dc_surface *dc_surface) ...@@ -162,6 +162,7 @@ void dc_surface_retain(const struct dc_surface *dc_surface)
{ {
struct surface *surface = DC_SURFACE_TO_SURFACE(dc_surface); struct surface *surface = DC_SURFACE_TO_SURFACE(dc_surface);
ASSERT(surface->ref_count > 0);
++surface->ref_count; ++surface->ref_count;
} }
...@@ -169,6 +170,7 @@ void dc_surface_release(const struct dc_surface *dc_surface) ...@@ -169,6 +170,7 @@ void dc_surface_release(const struct dc_surface *dc_surface)
{ {
struct surface *surface = DC_SURFACE_TO_SURFACE(dc_surface); struct surface *surface = DC_SURFACE_TO_SURFACE(dc_surface);
ASSERT(surface->ref_count > 0);
--surface->ref_count; --surface->ref_count;
if (surface->ref_count == 0) { if (surface->ref_count == 0) {
...@@ -181,12 +183,15 @@ void dc_gamma_retain(const struct dc_gamma *dc_gamma) ...@@ -181,12 +183,15 @@ void dc_gamma_retain(const struct dc_gamma *dc_gamma)
{ {
struct gamma *gamma = DC_GAMMA_TO_GAMMA(dc_gamma); struct gamma *gamma = DC_GAMMA_TO_GAMMA(dc_gamma);
ASSERT(gamma->ref_count > 0);
++gamma->ref_count; ++gamma->ref_count;
} }
void dc_gamma_release(const struct dc_gamma *dc_gamma) void dc_gamma_release(const struct dc_gamma *dc_gamma)
{ {
struct gamma *gamma = DC_GAMMA_TO_GAMMA(dc_gamma); struct gamma *gamma = DC_GAMMA_TO_GAMMA(dc_gamma);
ASSERT(gamma->ref_count > 0);
--gamma->ref_count; --gamma->ref_count;
if (gamma->ref_count == 0) if (gamma->ref_count == 0)
...@@ -200,7 +205,7 @@ struct dc_gamma *dc_create_gamma() ...@@ -200,7 +205,7 @@ struct dc_gamma *dc_create_gamma()
if (gamma == NULL) if (gamma == NULL)
goto alloc_fail; goto alloc_fail;
dc_gamma_retain(&gamma->protected.public); ++gamma->ref_count;
return &gamma->protected.public; return &gamma->protected.public;
...@@ -212,12 +217,15 @@ void dc_transfer_func_retain(const struct dc_transfer_func *dc_tf) ...@@ -212,12 +217,15 @@ void dc_transfer_func_retain(const struct dc_transfer_func *dc_tf)
{ {
struct transfer_func *tf = DC_TRANSFER_FUNC_TO_TRANSFER_FUNC(dc_tf); struct transfer_func *tf = DC_TRANSFER_FUNC_TO_TRANSFER_FUNC(dc_tf);
ASSERT(tf->ref_count > 0);
++tf->ref_count; ++tf->ref_count;
} }
void dc_transfer_func_release(const struct dc_transfer_func *dc_tf) void dc_transfer_func_release(const struct dc_transfer_func *dc_tf)
{ {
struct transfer_func *tf = DC_TRANSFER_FUNC_TO_TRANSFER_FUNC(dc_tf); struct transfer_func *tf = DC_TRANSFER_FUNC_TO_TRANSFER_FUNC(dc_tf);
ASSERT(tf->ref_count > 0);
--tf->ref_count; --tf->ref_count;
if (tf->ref_count == 0) if (tf->ref_count == 0)
...@@ -231,7 +239,7 @@ struct dc_transfer_func *dc_create_transfer_func() ...@@ -231,7 +239,7 @@ struct dc_transfer_func *dc_create_transfer_func()
if (tf == NULL) if (tf == NULL)
goto alloc_fail; goto alloc_fail;
dc_transfer_func_retain(&tf->protected.public); ++tf->ref_count;
return &tf->protected.public; return &tf->protected.public;
......
...@@ -71,6 +71,7 @@ void dc_target_retain(const struct dc_target *dc_target) ...@@ -71,6 +71,7 @@ void dc_target_retain(const struct dc_target *dc_target)
{ {
struct target *target = DC_TARGET_TO_TARGET(dc_target); struct target *target = DC_TARGET_TO_TARGET(dc_target);
ASSERT(target->ref_count > 0);
target->ref_count++; target->ref_count++;
} }
...@@ -81,6 +82,7 @@ void dc_target_release(const struct dc_target *dc_target) ...@@ -81,6 +82,7 @@ void dc_target_release(const struct dc_target *dc_target)
ASSERT(target->ref_count > 0); ASSERT(target->ref_count > 0);
target->ref_count--; target->ref_count--;
if (target->ref_count == 0) { if (target->ref_count == 0) {
destruct(protected); destruct(protected);
dm_free(target); dm_free(target);
...@@ -120,7 +122,7 @@ struct dc_target *dc_create_target_for_streams( ...@@ -120,7 +122,7 @@ struct dc_target *dc_create_target_for_streams(
construct(&target->protected, stream->ctx, dc_streams, stream_count); construct(&target->protected, stream->ctx, dc_streams, stream_count);
dc_target_retain(&target->protected.public); target->ref_count++;
return &target->protected.public; return &target->protected.public;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment