|
30 | 30 | #include <errno.h>
|
31 | 31 | #include <glib.h>
|
32 | 32 | #include <gnome-keyring.h>
|
| 33 | +#include <gnome-keyring-memory.h> |
33 | 34 |
|
34 | 35 | /*
|
35 | 36 | * This credential struct and API is simplified from git's credential.{h,c}
|
@@ -60,16 +61,6 @@ struct credential_operation
|
60 | 61 |
|
61 | 62 | /* ---------------- common helper functions ----------------- */
|
62 | 63 |
|
63 |
| -static inline void free_password(char *password) |
64 |
| -{ |
65 |
| - char *c = password; |
66 |
| - if (!password) |
67 |
| - return; |
68 |
| - |
69 |
| - while (*c) *c++ = '\0'; |
70 |
| - free(password); |
71 |
| -} |
72 |
| - |
73 | 64 | static inline void warning(const char *fmt, ...)
|
74 | 65 | {
|
75 | 66 | va_list ap;
|
@@ -159,8 +150,8 @@ static int keyring_get(struct credential *c)
|
159 | 150 | /* pick the first one from the list */
|
160 | 151 | password_data = (GnomeKeyringNetworkPasswordData *) entries->data;
|
161 | 152 |
|
162 |
| - free_password(c->password); |
163 |
| - c->password = xstrdup(password_data->password); |
| 153 | + gnome_keyring_memory_free(c->password); |
| 154 | + c->password = gnome_keyring_memory_strdup(password_data->password); |
164 | 155 |
|
165 | 156 | if (!c->username)
|
166 | 157 | c->username = xstrdup(password_data->user);
|
@@ -291,7 +282,7 @@ static void credential_clear(struct credential *c)
|
291 | 282 | free(c->host);
|
292 | 283 | free(c->path);
|
293 | 284 | free(c->username);
|
294 |
| - free_password(c->password); |
| 285 | + gnome_keyring_memory_free(c->password); |
295 | 286 |
|
296 | 287 | credential_init(c);
|
297 | 288 | }
|
@@ -338,8 +329,8 @@ static int credential_read(struct credential *c)
|
338 | 329 | free(c->username);
|
339 | 330 | c->username = xstrdup(value);
|
340 | 331 | } else if (!strcmp(key, "password")) {
|
341 |
| - free_password(c->password); |
342 |
| - c->password = xstrdup(value); |
| 332 | + gnome_keyring_memory_free(c->password); |
| 333 | + c->password = gnome_keyring_memory_strdup(value); |
343 | 334 | while (*value) *value++ = '\0';
|
344 | 335 | }
|
345 | 336 | /*
|
|
0 commit comments