[waffle] [PATCH 01/10] wegl: enable deriving from wegl_context
Chad Versace
chad.versace at intel.com
Thu Apr 9 15:52:01 PDT 2015
On Mon 30 Mar 2015, Frank Henigman wrote:
>Factor out init and teardown functions from create and destroy
>so a derived class can use them on its embedded wegl_context object.
>
>Signed-off-by: Frank Henigman <fjhenigman at google.com>
>---
> src/waffle/egl/wegl_context.c | 79 +++++++++++++++++++++++++++----------------
> src/waffle/egl/wegl_context.h | 10 ++++--
> 2 files changed, 57 insertions(+), 32 deletions(-)
>+struct wcore_context*
>+wegl_context_create(struct wcore_platform *wc_plat,
>+ struct wcore_config *wc_config,
>+ struct wcore_context *wc_share_ctx)
>+{
>+ struct wegl_context *ctx;
>+
>+ (void) wc_plat;
>+
>+ ctx = wcore_calloc(sizeof(*ctx));
>+ if (!ctx)
>+ return NULL;
>+
>+ if (wegl_context_init(ctx, wc_config, wc_share_ctx))
>+ return &ctx->wcore;
>+
> wegl_context_destroy(&ctx->wcore);
> return NULL;
> }
Throughout Waffle's codebase, I've tried to follow a pattern I've
observed in Go's standard style:
A function's normal control should be unobscured and easily read
from top to bottom. Deviations from normal flow, such as error
cases, should be indented instead of the normal flow.
Waffle's codebase is fairly consistent in that pattern, and this
function shouldn't be an exception.
It should look like this:
{
struct wegl_context *ctx;
(void) wc_plat;
ctx = wcore_calloc(sizeof(*ctx));
if (!ctx)
return NULL;
if (!wegl_context_init(ctx, wc_config, wc_share_ctx)) {
wegl_context_destroy(&ctx->wcore);
return NULL;
}
return &ctx->wcore;
}
Other than the style issue in this function, the patch looks good to me.
Fix that and patch 1 is
Reviewed-by: Chad Versace <chad.versace at intel.com>
>--
>2.2.0.rc0.207.ga3a616c
Do you build git from source?
More information about the waffle
mailing list