if (success) {
printf ("Got identity: %s %s %s\n", nai, password, server_certificate_hash);
+
+ moonshot_free (nai);
+ moonshot_free (password);
+ moonshot_free (server_certificate_hash);
+ moonshot_free (ca_certificate);
+ moonshot_free (subject_name_constraint);
+ moonshot_free (subject_alt_name_constraint);
+
return 0;
} else {
printf ("Error: %s\n", error->message);
* waiting for calls.
*/
+void moonshot_free (void *data)
+{
+ g_free (data);
+}
+
static DBusGProxy *dbus_connect (MoonshotError **error)
{
DBusConnection *connection;
#define MOONSHOT_INSTALL_PATH_KEY "Software\\Moonshot"
void *__RPC_USER MIDL_user_allocate (size_t size) {
- return malloc (size);
+ return malloc (size);
}
void __RPC_USER MIDL_user_free (void *data) {
- free (data);
+ if (data == NULL)
+ return;
+
+ free (data);
+}
+
+void moonshot_free (void *data)
+{
+ free (data);
}
static MoonshotError *moonshot_error_new_from_status (MoonshotErrorCode code,
#ifndef __LIBMOONSHOT_H
#define __LIBMOONSHOT_H
+/**
+ * moonshot_free:
+ * @pointer: pointer to be freed
+ *
+ * All the strings returned by the get_identity() functions must be
+ * freed using this function when they are no longer needed.
+ *
+ * @pointer may be %NULL, in which case no action is taken.
+ */
+void moonshot_free (void *data);
+
typedef enum {
MOONSHOT_ERROR_UNABLE_TO_START_SERVICE,
MOONSHOT_ERROR_NO_IDENTITY_SELECTED,
char *message;
} MoonshotError;
+/**
+ * moonshot_error_free:
+ * @error: A #MoonshotError
+ *
+ * Releases the memory used by @error. This function must be called if
+ * a function has returned an error, once it has been reported.
+ */
void moonshot_error_free (MoonshotError *error);
/**
/*if (success)
g_print ("Got id: %s %s\n", nai, password);*/
+ moonshot_free (nai);
+ moonshot_free (password);
+ moonshot_free (server_certificate_hash);
+ moonshot_free (ca_certificate);
+ moonshot_free (subject_name_constraint);
+ moonshot_free (subject_alt_name_constraint);
+
return GINT_TO_POINTER (success);
}