MXS-1220: Make server JSON functions const correct

The functions now take const parameters.

Also fixed a memory leak.
This commit is contained in:
Markus Mäkelä 2017-04-17 13:49:20 +03:00 committed by Markus Mäkelä
parent caf2172677
commit 13cba2cb75
2 changed files with 3 additions and 2 deletions

View File

@ -273,7 +273,7 @@ bool server_is_mxs_service(const SERVER *server);
*
* @return JSON representation of server or NULL if an error occurred
*/
json_t* server_to_json(SERVER* server);
json_t* server_to_json(const SERVER* server);
/**
* @brief Convert all servers into JSON format

View File

@ -444,6 +444,7 @@ dprintAllServersJson(DCB *dcb)
char* dump = json_dumps(all_servers, JSON_INDENT(4));
dcb_printf(dcb, "%s", dump);
MXS_FREE(dump);
json_decref(all_servers);
}
/**
@ -1394,7 +1395,7 @@ json_t* server_list_to_json()
return rval;
}
json_t* server_to_json(SERVER* server)
json_t* server_to_json(const SERVER* server)
{
// TODO: Add error checks
json_t* rval = json_object();