summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryce Harrington <bryce@osg.samsung.com>2016-04-06 11:50:26 -0700
committerBryce Harrington <bryce@osg.samsung.com>2016-04-06 12:20:57 -0700
commitd677d1c303daadbd621624c4af6042aa92cf8d99 (patch)
tree7688093d19cb124c9e99b6ccdf9da42df4fce49b
parentcbbb8c4fe528ad66b94710584aeee5a2cce72e33 (diff)
Enforce destruction of all backend config objects after initialization
Since the backend config struct versioning implies that there we expect potential future descrepancy between main's definition of the config object and the backend's, don't allow the backend to hang onto the config object outside the initialization scope.
-rw-r--r--src/main.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/main.c b/src/main.c
index afd412d2..b5baa0e3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -657,7 +657,20 @@ load_backend_old(struct weston_compositor *compositor, const char *backend,
return backend_init(compositor, argc, argv, wc, NULL);
}
-/* Temporary function to be replaced by weston_compositor_load_backend(). */
+/** Main module call-point for backends.
+ *
+ * All backends should use this routine to access their init routine.
+ * Backends may subclass weston_backend_config to add their own
+ * configuration data, setting the major/minor version in config_base
+ * accordingly.
+ *
+ * The config_base object should be treated as temporary, and any data
+ * copied out of it by backend_init before returning. The load_backend_new
+ * callers may then free the config_base object.
+ *
+ * NOTE: This is a temporary function intended to eventually be replaced
+ * by weston_compositor_load_backend().
+ */
static int
load_backend_new(struct weston_compositor *compositor, const char *backend,
struct weston_backend_config *config_base)
@@ -796,11 +809,10 @@ load_headless_backend(struct weston_compositor *c, char const * backend,
config->base.struct_size = sizeof(struct weston_headless_backend_config);
/* load the actual wayland backend and configure it */
- if (load_backend_new(c, backend,
- (struct weston_backend_config *)config) < 0) {
- ret = -1;
- free(config);
- }
+ ret = load_backend_new(c, backend,
+ (struct weston_backend_config *)config);
+
+ free(config);
return ret;
}
@@ -898,7 +910,7 @@ load_x11_backend(struct weston_compositor *c, char const * backend,
if (weston_x11_backend_config_append_output_config(config, &current_output) < 0) {
ret = -1;
- goto error;
+ goto out;
}
output_count++;
@@ -919,7 +931,7 @@ load_x11_backend(struct weston_compositor *c, char const * backend,
if (weston_x11_backend_config_append_output_config(config, &default_output) < 0) {
ret = -1;
- goto error;
+ goto out;
}
}
@@ -930,16 +942,15 @@ load_x11_backend(struct weston_compositor *c, char const * backend,
if (load_backend_new(c, backend,
(struct weston_backend_config *)config) < 0) {
ret = -1;
- goto error;
+ goto out;
}
- return ret;
-
-error:
+out:
for (j = 0; j < config->num_outputs; ++j)
free(config->outputs[j].name);
free(config->outputs);
free(config);
+
return ret;
}