Mercurial > pidgin
comparison src/protocols/novell/nmrequest.c @ 9360:d77537e8bfe5
[gaim-migrate @ 10168]
" This patch fixes contact list sync problem, fixes a
memory leak, and includes some code cleanup." --Mike Stoddard of Novell
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Wed, 23 Jun 2004 17:27:56 +0000 |
| parents | 6663ad2386d9 |
| children |
comparison
equal
deleted
inserted
replaced
| 9359:43741d8f76f7 | 9360:d77537e8bfe5 |
|---|---|
| 18 * | 18 * |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #include "nmrequest.h" | 21 #include "nmrequest.h" |
| 22 | 22 |
| 23 static int count = 0; | |
| 24 | |
| 23 struct _NMRequest | 25 struct _NMRequest |
| 24 { | 26 { |
| 25 int trans_id; | 27 int trans_id; |
| 26 char *cmd; | 28 char *cmd; |
| 27 int gmt; | 29 int gmt; |
| 30 nm_response_cb callback; | 32 nm_response_cb callback; |
| 31 int ref_count; | 33 int ref_count; |
| 32 NMERR_T ret_code; | 34 NMERR_T ret_code; |
| 33 }; | 35 }; |
| 34 | 36 |
| 35 | 37 NMRequest *nm_create_request(const char *cmd, int trans_id, int gmt, nm_response_cb cb, |
| 36 NMRequest * | 38 gpointer resp_data, gpointer user_define) |
| 37 nm_create_request(const char *cmd, int trans_id, int gmt) | |
| 38 { | 39 { |
| 39 NMRequest *req; | 40 NMRequest *req; |
| 40 | 41 |
| 41 if (cmd == NULL) | 42 if (cmd == NULL) |
| 42 return NULL; | 43 return NULL; |
| 43 | 44 |
| 44 req = g_new0(NMRequest, 1); | 45 req = g_new0(NMRequest, 1); |
| 45 req->cmd = g_strdup(cmd); | 46 req->cmd = g_strdup(cmd); |
| 46 req->trans_id = trans_id; | 47 req->trans_id = trans_id; |
| 47 req->gmt = gmt; | 48 req->gmt = gmt; |
| 49 req->callback = cb; | |
| 50 req->data = resp_data; | |
| 51 req->user_define = user_define; | |
| 48 req->ref_count = 1; | 52 req->ref_count = 1; |
| 53 | |
| 54 gaim_debug_info("novell", "Creating NMRequest instance, total=%d\n", ++count); | |
| 49 | 55 |
| 50 return req; | 56 return req; |
| 51 } | 57 } |
| 52 | 58 |
| 53 void | 59 void |
| 55 { | 61 { |
| 56 if (req && (--req->ref_count == 0)) { | 62 if (req && (--req->ref_count == 0)) { |
| 57 if (req->cmd) | 63 if (req->cmd) |
| 58 g_free(req->cmd); | 64 g_free(req->cmd); |
| 59 g_free(req); | 65 g_free(req); |
| 66 | |
| 67 gaim_debug_info("novell", | |
| 68 "Releasing NMRequest instance, total=%d\n", --count); | |
| 60 } | 69 } |
| 70 | |
| 61 } | 71 } |
| 62 | 72 |
| 63 void | 73 void |
| 64 nm_request_add_ref(NMRequest * req) | 74 nm_request_add_ref(NMRequest * req) |
| 65 { | 75 { |
