27
27
#include <string.h>
28
28
#include <stdarg.h>
29
29
#include <stdlib.h>
30
- #include <errno.h>
31
30
#include <glib.h>
32
31
#include <gnome-keyring.h>
33
32
#include <gnome-keyring-memory.h>
@@ -83,21 +82,6 @@ static inline void error(const char *fmt, ...)
83
82
va_end (ap );
84
83
}
85
84
86
- static inline void die_errno (int err )
87
- {
88
- error ("%s" , strerror (err ));
89
- exit (EXIT_FAILURE );
90
- }
91
-
92
- static inline char * xstrdup (const char * str )
93
- {
94
- char * ret = strdup (str );
95
- if (!ret )
96
- die_errno (errno );
97
-
98
- return ret ;
99
- }
100
-
101
85
/* ----------------- GNOME Keyring functions ----------------- */
102
86
103
87
/* create a special keyring option string, if path is given */
@@ -134,7 +118,7 @@ static int keyring_get(struct credential *c)
134
118
c -> port ,
135
119
& entries );
136
120
137
- free (object );
121
+ g_free (object );
138
122
139
123
if (result == GNOME_KEYRING_RESULT_NO_MATCH )
140
124
return EXIT_SUCCESS ;
@@ -154,7 +138,7 @@ static int keyring_get(struct credential *c)
154
138
c -> password = gnome_keyring_memory_strdup (password_data -> password );
155
139
156
140
if (!c -> username )
157
- c -> username = xstrdup (password_data -> user );
141
+ c -> username = g_strdup (password_data -> user );
158
142
159
143
gnome_keyring_network_password_list_free (entries );
160
144
@@ -192,7 +176,7 @@ static int keyring_store(struct credential *c)
192
176
c -> password ,
193
177
& item_id );
194
178
195
- free (object );
179
+ g_free (object );
196
180
return EXIT_SUCCESS ;
197
181
}
198
182
@@ -226,7 +210,7 @@ static int keyring_erase(struct credential *c)
226
210
c -> port ,
227
211
& entries );
228
212
229
- free (object );
213
+ g_free (object );
230
214
231
215
if (result == GNOME_KEYRING_RESULT_NO_MATCH )
232
216
return EXIT_SUCCESS ;
@@ -278,10 +262,10 @@ static void credential_init(struct credential *c)
278
262
279
263
static void credential_clear (struct credential * c )
280
264
{
281
- free (c -> protocol );
282
- free (c -> host );
283
- free (c -> path );
284
- free (c -> username );
265
+ g_free (c -> protocol );
266
+ g_free (c -> host );
267
+ g_free (c -> path );
268
+ g_free (c -> username );
285
269
gnome_keyring_memory_free (c -> password );
286
270
287
271
credential_init (c );
@@ -315,22 +299,22 @@ static int credential_read(struct credential *c)
315
299
* value ++ = '\0' ;
316
300
317
301
if (!strcmp (key , "protocol" )) {
318
- free (c -> protocol );
319
- c -> protocol = xstrdup (value );
302
+ g_free (c -> protocol );
303
+ c -> protocol = g_strdup (value );
320
304
} else if (!strcmp (key , "host" )) {
321
- free (c -> host );
322
- c -> host = xstrdup (value );
305
+ g_free (c -> host );
306
+ c -> host = g_strdup (value );
323
307
value = strrchr (c -> host ,':' );
324
308
if (value ) {
325
309
* value ++ = '\0' ;
326
310
c -> port = atoi (value );
327
311
}
328
312
} else if (!strcmp (key , "path" )) {
329
- free (c -> path );
330
- c -> path = xstrdup (value );
313
+ g_free (c -> path );
314
+ c -> path = g_strdup (value );
331
315
} else if (!strcmp (key , "username" )) {
332
- free (c -> username );
333
- c -> username = xstrdup (value );
316
+ g_free (c -> username );
317
+ c -> username = g_strdup (value );
334
318
} else if (!strcmp (key , "password" )) {
335
319
gnome_keyring_memory_free (c -> password );
336
320
c -> password = gnome_keyring_memory_strdup (value );
0 commit comments