Changeset 7528
- Timestamp:
- Dec 29, 2008, 6:10:07 PM (12 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-msgs.c
r7476 r7528 297 297 tr_torrent * torrent; 298 298 299 tr_publisher _t *publisher;299 tr_publisher publisher; 300 300 301 301 struct evbuffer * outMessages; /* all the non-piece messages */ … … 531 531 assert( msgs->peer->msgs == msgs ); 532 532 533 tr_publisherPublish( msgs->publisher, msgs->peer, e );533 tr_publisherPublish( &msgs->publisher, msgs->peer, e ); 534 534 } 535 535 … … 2210 2210 2211 2211 m = tr_new0( tr_peermsgs, 1 ); 2212 m->publisher = tr_publisherNew( );2212 m->publisher = TR_PUBLISHER_INIT; 2213 2213 m->peer = peer; 2214 2214 m->session = torrent->session; … … 2230 2230 peer->msgs = m; 2231 2231 2232 *setme = tr_publisherSubscribe( m->publisher, func, userData );2232 *setme = tr_publisherSubscribe( &m->publisher, func, userData ); 2233 2233 2234 2234 if( tr_peerIoSupportsLTEP( peer->io ) ) … … 2249 2249 { 2250 2250 tr_timerFree( &msgs->pexTimer ); 2251 tr_publisher Free( &msgs->publisher );2251 tr_publisherDestruct( &msgs->publisher ); 2252 2252 reqListClear( &msgs->clientWillAskFor ); 2253 2253 reqListClear( &msgs->clientAskedFor ); … … 2268 2268 tr_publisher_tag tag ) 2269 2269 { 2270 tr_publisherUnsubscribe( peer->publisher, tag );2271 } 2272 2270 tr_publisherUnsubscribe( &peer->publisher, tag ); 2271 } 2272 -
trunk/libtransmission/publish.c
r7404 r7528 22 22 }; 23 23 24 struct tr_publisher_s 25 { 26 tr_list * list; 27 }; 28 29 tr_publisher_t* 30 tr_publisherNew( void ) 31 { 32 return tr_new0( tr_publisher_t, 1 ); 33 } 24 const tr_publisher TR_PUBLISHER_INIT = { NULL }; 34 25 35 26 void 36 tr_publisher Free( tr_publisher_t ** p )27 tr_publisherDestruct( tr_publisher * p ) 37 28 { 38 assert( p ); 39 assert( *p ); 40 41 tr_list_free( &( *p )->list, NULL ); 42 tr_free( *p ); 43 *p = NULL; 29 tr_list_free( &p->list, NULL ); 44 30 } 45 31 46 32 tr_publisher_tag 47 tr_publisherSubscribe( tr_publisher _t* p,48 tr_delivery_func func,49 void * user_data )33 tr_publisherSubscribe( tr_publisher * p, 34 tr_delivery_func func, 35 void * user_data ) 50 36 { 51 37 struct tr_publisher_node * node = tr_new( struct tr_publisher_node, 1 ); … … 58 44 59 45 void 60 tr_publisherUnsubscribe( tr_publisher _t* p,46 tr_publisherUnsubscribe( tr_publisher * p, 61 47 tr_publisher_tag tag ) 62 48 { … … 66 52 67 53 void 68 tr_publisherPublish( tr_publisher _t* p,54 tr_publisherPublish( tr_publisher * p, 69 55 void * source, 70 56 void * event ) -
trunk/libtransmission/publish.h
r7404 r7528 18 18 #define _TR_PUBLISHER_H_ 19 19 20 struct tr_list; 21 20 22 /** 21 23 *** A lightweight implementation of the 'Observable' design pattern. 22 24 **/ 23 25 24 typedef struct tr_publisher_s tr_publisher_t; 26 typedef struct tr_publisher 27 { 28 struct tr_list * list; 29 } 30 tr_publisher; 25 31 26 32 typedef void * tr_publisher_tag; … … 34 40 **/ 35 41 36 tr_publisher_tag tr_publisherSubscribe( tr_publisher _t* publisher,42 tr_publisher_tag tr_publisherSubscribe( tr_publisher * publisher, 37 43 tr_delivery_func delivery_func, 38 44 void * user_data ); 39 45 40 void tr_publisherUnsubscribe( tr_publisher _t* publisher,46 void tr_publisherUnsubscribe( tr_publisher * publisher, 41 47 tr_publisher_tag tag ); 42 48 … … 45 51 **/ 46 52 47 tr_publisher_t * tr_publisherNew( void );53 extern const tr_publisher TR_PUBLISHER_INIT; 48 54 49 void tr_publisher Free( tr_publisher_t ** publisher);55 void tr_publisherDestruct( tr_publisher * ); 50 56 51 void tr_publisherPublish( tr_publisher _t* publisher,57 void tr_publisherPublish( tr_publisher * publisher, 52 58 void * source, 53 59 void * event ); -
trunk/libtransmission/tracker.c
r7476 r7528 93 93 tr_session * session; 94 94 95 tr_publisher _t *publisher;95 tr_publisher publisher; 96 96 97 97 /* torrent hash string */ … … 200 200 event.messageType = type; 201 201 event.text = msg; 202 tr_publisherPublish( t->publisher, t, &event );202 tr_publisherPublish( &t->publisher, t, &event ); 203 203 } 204 204 } … … 239 239 event.compactLen = compactLen; 240 240 if( compactLen ) 241 tr_publisherPublish( t->publisher, t, &event );241 tr_publisherPublish( &t->publisher, t, &event ); 242 242 } 243 243 … … 1049 1049 1050 1050 t = tr_new0( tr_tracker, 1 ); 1051 t->publisher = tr_publisherNew( );1051 t->publisher = TR_PUBLISHER_INIT; 1052 1052 t->session = torrent->session; 1053 1053 t->scrapeIntervalSec = DEFAULT_SCRAPE_INTERVAL_SEC; … … 1082 1082 tr_tracker * t = vt; 1083 1083 1084 tr_publisher Free( &t->publisher );1084 tr_publisherDestruct( &t->publisher ); 1085 1085 tr_free( t->name ); 1086 1086 tr_free( t->trackerID ); … … 1106 1106 void * user_data ) 1107 1107 { 1108 return tr_publisherSubscribe( t->publisher, func, user_data );1108 return tr_publisherSubscribe( &t->publisher, func, user_data ); 1109 1109 } 1110 1110 … … 1114 1114 { 1115 1115 if( t ) 1116 tr_publisherUnsubscribe( t->publisher, tag );1116 tr_publisherUnsubscribe( &t->publisher, tag ); 1117 1117 } 1118 1118
Note: See TracChangeset
for help on using the changeset viewer.