commands: Code formatting.

master
S. Christoffer Eliesen 9 years ago
parent 187f0ab1c4
commit 88a2ddbe83

@ -1329,19 +1329,21 @@ struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, c
} }
void free_cmd_results(struct cmd_results *results) { void free_cmd_results(struct cmd_results *results) {
if (results->error) if (results->error) {
free(results->error); free(results->error);
}
free(results); free(results);
} }
const char *cmd_results_to_json(struct cmd_results *results) { const char *cmd_results_to_json(struct cmd_results *results) {
json_object *root = json_object_new_object(); json_object *root = json_object_new_object();
json_object_object_add(root, "success", json_object_new_boolean(results->status == CMD_SUCCESS)); json_object_object_add(root, "success", json_object_new_boolean(results->status == CMD_SUCCESS));
if (results->input) if (results->input) {
json_object_object_add(root, "input", json_object_new_string(results->input)); json_object_object_add(root, "input", json_object_new_string(results->input));
if (results->error) }
if (results->error) {
json_object_object_add(root, "error", json_object_new_string(results->error)); json_object_object_add(root, "error", json_object_new_string(results->error));
}
const char *json = json_object_to_json_string(root); const char *json = json_object_to_json_string(root);
free(root); free(root);
return json; return json;

Loading…
Cancel
Save