+ binding_workspace_names = srealloc(binding_workspace_names, ++n * sizeof(char *));
+ binding_workspace_names[n - 1] = target_name;
+ }
+ binding_workspace_names = srealloc(binding_workspace_names, ++n * sizeof(char *));
+ binding_workspace_names[n - 1] = NULL;
+}
+
+/*
+ * Returns a pointer to a new workspace in the given output. The workspace
+ * is created attached to the tree hierarchy through the given content
+ * container.
+ *
+ */
+Con *create_workspace_on_output(Output *output, Con *content) {
+ /* add a workspace to this output */
+ Con *out, *current;
+ char *name;
+ bool exists = true;
+ Con *ws = con_new(NULL, NULL);
+ ws->type = CT_WORKSPACE;
+
+ /* try the configured workspace bindings first to find a free name */
+ for (int n = 0; binding_workspace_names[n] != NULL; n++) {
+ char *target_name = binding_workspace_names[n];