Changeset 927f27d8c6feedb36da0b1e442bb897e2be6f90e
- Timestamp:
- 12/17/07 21:27:03
(9 months ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1197923223 +0000
- git-parent:
[cbe2c26778b462d055750a1160b386d2024be7fb]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1197923223 +0000
- Message:
Save one memory copy and fix the helper module leak
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r2bca4f1 |
r927f27d |
|
| 122 | 122 | #define vlc_module_end( ) \ |
|---|
| 123 | 123 | } \ |
|---|
| 124 | | res = config_Duplicate( p_module, p_config, ++i_config ); \ |
|---|
| 125 | | free( p_config ); \ |
|---|
| 126 | | if (res) \ |
|---|
| 127 | | return res; \ |
|---|
| 128 | | return VLC_SUCCESS; \ |
|---|
| | 124 | return config_Duplicate( p_module, p_config, ++i_config ); \ |
|---|
| 129 | 125 | \ |
|---|
| 130 | 126 | error: \ |
|---|
| 131 | | free( p_config ); \ |
|---|
| | 127 | /* FIXME: config_Free( p_config ); */ \ |
|---|
| 132 | 128 | /* FIXME: cleanup submodules objects ??? */ \ |
|---|
| 133 | 129 | return VLC_EGENERIC; \ |
|---|
| rcbe2c26 |
r927f27d |
|
| 493 | 493 | |
|---|
| 494 | 494 | /* Calculate the structure length */ |
|---|
| 495 | | p_module->i_config_items = 0; |
|---|
| 496 | | p_module->i_bool_items = 0; |
|---|
| 497 | | |
|---|
| 498 | 495 | for( p_item = p_orig; p_item < p_end; p_item++ ) |
|---|
| 499 | 496 | { |
|---|
| … | … | |
| 509 | 506 | } |
|---|
| 510 | 507 | |
|---|
| 511 | | /* Allocate memory */ |
|---|
| 512 | | p_module->p_config = (module_config_t *)calloc( n, sizeof(*p_orig) ); |
|---|
| 513 | | if( p_module->p_config == NULL ) |
|---|
| 514 | | { |
|---|
| 515 | | msg_Err( p_module, "config error: can't duplicate p_config" ); |
|---|
| 516 | | return VLC_ENOMEM; |
|---|
| 517 | | } |
|---|
| | 508 | p_module->p_config = p_orig; |
|---|
| 518 | 509 | p_module->confsize = n; |
|---|
| 519 | 510 | |
|---|
| … | … | |
| 521 | 512 | for( size_t i = 0; i < n ; i++ ) |
|---|
| 522 | 513 | { |
|---|
| 523 | | p_module->p_config[i] = p_orig[i]; |
|---|
| 524 | 514 | p_module->p_config[i].p_lock = &p_module->object_lock; |
|---|
| 525 | 515 | } |
|---|
| rcbe2c26 |
r927f27d |
|
| 41 | 41 | module->psz_capability = ""; |
|---|
| 42 | 42 | module->i_score = 1; |
|---|
| | 43 | module->i_config_items = module->i_bool_items = 0; |
|---|
| | 44 | |
|---|
| 43 | 45 | return module; |
|---|
| 44 | 46 | } |
|---|
| … | … | |
| 162 | 164 | tab[confsize].p_lock = &module->object_lock; |
|---|
| 163 | 165 | |
|---|
| | 166 | if (type & CONFIG_ITEM) |
|---|
| | 167 | { |
|---|
| | 168 | module->i_config_items++; |
|---|
| | 169 | if (type == CONFIG_ITEM_BOOL) |
|---|
| | 170 | module->i_bool_items++; |
|---|
| | 171 | } |
|---|
| | 172 | |
|---|
| 164 | 173 | return tab + confsize; |
|---|
| 165 | 174 | } |
|---|