diff --git a/main.c b/main.c index 89e346c..1e1b791 100644 --- a/main.c +++ b/main.c @@ -51,6 +51,7 @@ int main(int argc,char *argv[]) char path[256]; time = clock(); + curl_global_init(CURL_GLOBAL_DEFAULT); printf("time:%f\n",(float)time / CLOCKS_PER_SEC); @@ -59,6 +60,7 @@ int main(int argc,char *argv[]) if(dbus_error_is_set(&error)) { fprintf(stderr,"%s",error.message); + dbus_error_free(&error); return -1; } printf("This is my unique dbus name: %s\n",dbus_bus_get_unique_name(connection)); @@ -159,6 +161,7 @@ int main(int argc,char *argv[]) { fprintf(stderr,HELP_TEXT); } + curl_global_cleanup(); return 0; } int getPath(char *configPath,int size) @@ -182,6 +185,7 @@ int DBusOptions(DBusConnection *connection,DBusError **error) //not tested check if(dbus_error_is_set(*error)) { fprintf(stderr,"%s",(**error).message); + dbus_error_free(*error); return -1; }else { @@ -273,7 +277,7 @@ int gotify_message(char *url,char *title,char *message) char post_buffer[128]; char url_buffer[128]; long response_code; - + curl = curl_easy_init(); const char* token = NULL; @@ -328,7 +332,7 @@ int gotify_message(char *url,char *title,char *message) { printf("Error on string concelblalbla: %d\n",ret); } - + curl_easy_cleanup(curl); return 0; } @@ -430,6 +434,7 @@ int systemdCall(DBusConnection *connection,char *method,char *param) if(dbus_error_is_set(&error)) { fprintf(stderr,"%s\n",error.message); + dbus_error_free(&error); return -1; } return 0; @@ -456,6 +461,7 @@ int systemdUnitCall(DBusConnection *connection,char *target,char *method,char *p if(NULL == msg) { fprintf(stderr,"Message null, no message created\n"); + dbus_message_unref(msg); return 1; } @@ -465,11 +471,13 @@ int systemdUnitCall(DBusConnection *connection,char *target,char *method,char *p if(!dbus_message_iter_append_basic(&iter,DBUS_TYPE_STRING,¶m2)) { fprintf(stderr,"Error appending\n"); + dbus_message_unref(msg); return -1; } if(!dbus_message_iter_append_basic(&iter,DBUS_TYPE_STRING,¶m)) { fprintf(stderr,"Error appending\n"); + dbus_message_unref(msg); return -1; } } @@ -478,6 +486,8 @@ int systemdUnitCall(DBusConnection *connection,char *target,char *method,char *p if(ret_msg == NULL) { fprintf(stderr,"error ond receiving message from peer\n"); + dbus_message_unref(msg); + dbus_message_unref(ret_msg); return 1; } else @@ -511,6 +521,7 @@ int systemdUnitCall(DBusConnection *connection,char *target,char *method,char *p dbus_message_iter_get_basic(&variant_iter,result); //printf("*result:%s\n",*result); } + dbus_free(type); } if(ret1 == DBUS_TYPE_ARRAY) { @@ -542,8 +553,13 @@ int systemdUnitCall(DBusConnection *connection,char *target,char *method,char *p if(dbus_error_is_set(&error)) { fprintf(stderr,"%s\n",error.message); + dbus_error_free(&error); + dbus_message_unref(msg); + dbus_message_unref(ret_msg); return 1; } + dbus_message_unref(msg); + dbus_message_unref(ret_msg); return 0; }