Changeset 85dfdfdde360f9a5de9ab8243123cfdd83efd5c1
- Timestamp:
- 26/03/08 23:58:05
(7 months ago)
- Author:
- Pierre d'Herbemont <pdherbemont@videolan.org>
- git-committer:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1206572285 +0100
- git-parent:
[00d044a3c74bce8f109a342a197f66b948c4892c]
- git-author:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1206572178 +0100
- Message:
sap: Properly manage object memory.
Use an vlc_object_t destructor.
Don't use free, instead of vlc_object_release().
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| ra78e273 |
r85dfdfd |
|
| 181 | 181 | if( p_announce->p_sap ) |
|---|
| 182 | 182 | { |
|---|
| 183 | | vlc_object_kill ((vlc_object_t *)p_announce->p_sap); |
|---|
| 184 | | /* Wait for the SAP thread to exit */ |
|---|
| 185 | | vlc_thread_join( (vlc_object_t *)p_announce->p_sap ); |
|---|
| 186 | | announce_SAPHandlerDestroy( p_announce->p_sap ); |
|---|
| | 183 | /* Exit the SAP */ |
|---|
| | 184 | vlc_object_release( p_announce->p_sap ); |
|---|
| 187 | 185 | } |
|---|
| 188 | 186 | |
|---|
| ra78e273 |
r85dfdfd |
|
| 107 | 107 | session_descriptor_t *p_session ); |
|---|
| 108 | 108 | |
|---|
| | 109 | static void announce_SAPHandlerDestructor( vlc_object_t *p_this ); |
|---|
| | 110 | |
|---|
| 109 | 111 | |
|---|
| 110 | 112 | /** |
|---|
| … | … | |
| 141 | 143 | { |
|---|
| 142 | 144 | msg_Dbg( p_announce, "unable to spawn SAP handler thread"); |
|---|
| 143 | | free( p_sap ); |
|---|
| | 145 | vlc_object_release( p_sap ); |
|---|
| 144 | 146 | return NULL; |
|---|
| 145 | | }; |
|---|
| | 147 | } |
|---|
| | 148 | |
|---|
| | 149 | vlc_object_set_destructor( p_sap, announce_SAPHandlerDestructor ); |
|---|
| | 150 | |
|---|
| 146 | 151 | msg_Dbg( p_announce, "thread created, %i sessions", p_sap->i_sessions); |
|---|
| | 152 | |
|---|
| 147 | 153 | return p_sap; |
|---|
| 148 | 154 | } |
|---|
| 149 | 155 | |
|---|
| 150 | | /** |
|---|
| 151 | | * Destroy the SAP handler |
|---|
| 152 | | * \param p_this the SAP Handler to destroy |
|---|
| 153 | | * \return nothing |
|---|
| 154 | | */ |
|---|
| 155 | | void announce_SAPHandlerDestroy( sap_handler_t *p_sap ) |
|---|
| 156 | | { |
|---|
| | 156 | static void announce_SAPHandlerDestructor( vlc_object_t * p_this ) |
|---|
| | 157 | { |
|---|
| | 158 | sap_handler_t *p_sap = (sap_handler_t *)p_this; |
|---|
| 157 | 159 | int i; |
|---|
| 158 | | |
|---|
| 159 | | vlc_mutex_destroy( &p_sap->object_lock ); |
|---|
| 160 | 160 | |
|---|
| 161 | 161 | /* Free the remaining sessions */ |
|---|
| … | … | |
| 184 | 184 | FREENULL( p_address ); |
|---|
| 185 | 185 | } |
|---|
| 186 | | |
|---|
| 187 | | /* Free the structure */ |
|---|
| 188 | | vlc_object_release( p_sap ); |
|---|
| 189 | 186 | } |
|---|
| 190 | 187 | |
|---|
| r0d15cad |
r85dfdfd |
|
| 99 | 99 | int announce_HandlerDestroy( announce_handler_t * ); |
|---|
| 100 | 100 | |
|---|
| | 101 | /* Release it with vlc_object_release() */ |
|---|
| 101 | 102 | sap_handler_t *announce_SAPHandlerCreate( announce_handler_t *p_announce ); |
|---|
| 102 | | void announce_SAPHandlerDestroy( sap_handler_t *p_sap ); |
|---|
| 103 | 103 | |
|---|
| 104 | 104 | #endif |
|---|