+/*
+ * Creates a dynamically allocated copy of bind.
+ */
+static Binding *binding_copy(Binding *bind) {
+ Binding *ret = smalloc(sizeof(Binding));
+ *ret = *bind;
+ if (bind->symbol != NULL)
+ ret->symbol = strdup(bind->symbol);
+ if (bind->command != NULL)
+ ret->command = strdup(bind->command);
+ if (bind->translated_to != NULL) {
+ ret->translated_to = smalloc(sizeof(xcb_keycode_t) * bind->number_keycodes);
+ memcpy(ret->translated_to, bind->translated_to, sizeof(xcb_keycode_t) * bind->number_keycodes);
+ }
+ return ret;
+}
+
+/*
+ * Frees the binding. If bind is null, it simply returns.
+ */
+void binding_free(Binding *bind) {
+ if (bind == NULL) {
+ return;
+ }
+
+ FREE(bind->symbol);
+ FREE(bind->translated_to);
+ FREE(bind->command);
+ FREE(bind);
+}
+