Skip to content
Snippets Groups Projects
Commit b2fc7ef0 authored by Jakob Olsson's avatar Jakob Olsson
Browse files

small memory leak fix, style change

parent 454979e8
No related branches found
No related tags found
No related merge requests found
......@@ -170,10 +170,9 @@ char *lexer(char **input, char *delimiter) {
if (token)
*token = '\0';
else {
printf("delimiter missing!\n");
else
return NULL;
}
char *substr = strdup(*input);
*input = token + strlen(delimiter);
......@@ -181,19 +180,6 @@ char *lexer(char **input, char *delimiter) {
return substr;
}
/**
* Function: parse_apn_profiles
*
* Takes a string of APN profile configurations provided by zte-mf823 (which is in an awkward, difficult to read format)
* and transforms them into a more easily read and worked with JSON format.
*
* Parameters:
* apn_profiles - A character string containing the APN profiles.
*
* Returns:
* The newly generated JSON on success.
* NULL on failure.
*/
struct json_object *parse_apn_profiles(char *apn_profiles)
{
if (strlen(apn_profiles) <= 0) {
......@@ -227,7 +213,8 @@ struct json_object *parse_apn_profiles(char *apn_profiles)
}
char name[1024];
sprintf(name, "%d", apn_counter);
json_object_object_add(parsed_profiles, name, apn_profile); //be careful here, do we need json_object_get(apn_profile)?
json_object_object_add(parsed_profiles, name, json_object_get(apn_profile));
json_object_put(apn_profile);
apn_counter++;
}
goto finished;
......
......@@ -40,7 +40,23 @@
* the caller is then responsible for freeing this memory by calling free(returned_pointer).
*
***************************************************/
/**
* __TEMPORARILY PLACED IN THIS HEAD__
* Function: parse_apn_profiles
*
* Takes a string of APN profile configurations provided by zte-mf823 (which is in an awkward, difficult to read format)
* and transforms them into a more easily read and worked with JSON format.
*
* Parameters:
* apn_profiles - A character string containing the APN profiles.
*
* Returns:
* The newly generated JSON on success.
* NULL on failure.
*/
struct json_object *parse_apn_profiles(char *apn_profiles);
/**
* Function: mobile_connect_network
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment