Changeset 5312:27ec111dc8c5 in roaraudio for libroar
- Timestamp:
- 11/30/11 01:05:41 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- libroar
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libroar/error.c
r5295 r5312 866 866 } 867 867 868 // Resets the stored state to 'no error' state. This can be used 869 // to init the state. 870 int roar_err_initstore(struct roar_error_state * state) { 871 struct roar_error_state curstate; 872 873 if ( state == NULL ) { 874 roar_err_set(ROAR_ERROR_FAULT); 875 return -1; 876 } 877 878 roar_err_store(&curstate); 879 roar_err_clear_all(); 880 roar_err_store(state); 881 roar_err_restore(&curstate); 882 883 return -1; 884 } 868 885 869 886 // store a error state (both libroar and system) -
libroar/roardl.c
r5275 r5312 43 43 struct roar_dl_librarypara * para; 44 44 struct roar_dl_libraryinst * lib; 45 struct { 46 struct roar_error_state error_state; 47 void * global_data; 48 void * global_data_state; 49 } context; 45 50 #if defined(ROAR_HAVE_LIBDL) 46 51 void * handle; … … 187 192 memset(ret, 0, sizeof(struct roar_dl_lhandle)); 188 193 194 roar_err_initstore(&(ret->context.error_state)); 195 189 196 #if defined(ROAR_HAVE_LIBDL) 190 197 flags = RTLD_NOW; … … 243 250 ret = -1; 244 251 #endif 252 253 if ( lhandle->context.global_data != NULL ) 254 roar_mm_free(lhandle->context.global_data); 245 255 246 256 if ( lhandle->para != NULL ) … … 273 283 struct roar_dl_libraryinst * (*func)(struct roar_dl_librarypara * para); 274 284 struct roar_dl_libraryinst * lib; 285 void * global_data_state = NULL; 275 286 int i; 276 287 … … 310 321 if ( !((void*)lhandle < (void*)128) ) { 311 322 lhandle->lib = lib; 323 324 if ( lib->global_data_len ) { 325 lhandle->context.global_data = roar_mm_malloc(lib->global_data_len); 326 if ( lhandle->context.global_data == NULL ) 327 return -1; 328 329 if ( lib->global_data_init == NULL ) { 330 memset(lhandle->context.global_data, 0, lib->global_data_len); 331 } else { 332 memcpy(lhandle->context.global_data, lib->global_data_init, lib->global_data_len); 333 } 334 } 335 } 336 337 if ( lib->global_data_pointer != NULL ) { 338 global_data_state = *(lib->global_data_pointer); 339 if ( !((void*)lhandle < (void*)128) ) { 340 *(lib->global_data_pointer) = lib->global_data_init; 341 } else { 342 *(lib->global_data_pointer) = lhandle->context.global_data; 343 } 312 344 } 313 345 … … 315 347 if ( lib->func[i] != NULL ) 316 348 lib->func[i](para, lib); 349 } 350 351 if ( lib->global_data_pointer != NULL ) { 352 *(lib->global_data_pointer) = global_data_state; 317 353 } 318 354 … … 375 411 } 376 412 413 int roar_dl_context_restore(struct roar_dl_lhandle * lhandle) { 414 struct roar_error_state error_state; 415 416 if ( (void*)lhandle < (void*)128 ) { 417 roar_err_set(ROAR_ERROR_NOTSUP); 418 return -1; 419 } 420 421 roar_err_store(&error_state); 422 roar_err_restore(&(lhandle->context.error_state)); 423 lhandle->context.error_state = error_state; 424 425 if ( lhandle->lib->global_data_pointer != NULL ) { 426 lhandle->context.global_data_state = *(lhandle->lib->global_data_pointer); 427 *(lhandle->lib->global_data_pointer) = lhandle->context.global_data; 428 } 429 430 return 0; 431 } 432 433 int roar_dl_context_store(struct roar_dl_lhandle * lhandle) { 434 struct roar_error_state error_state; 435 436 if ( (void*)lhandle < (void*)128 ) { 437 roar_err_set(ROAR_ERROR_NOTSUP); 438 return -1; 439 } 440 441 if ( lhandle->lib->global_data_pointer != NULL ) { 442 *(lhandle->lib->global_data_pointer) = lhandle->context.global_data_state; 443 } 444 445 roar_err_store(&error_state); 446 roar_err_restore(&(lhandle->context.error_state)); 447 lhandle->context.error_state = error_state; 448 449 return 0; 450 } 451 377 452 //ll
Note: See TracChangeset
for help on using the changeset viewer.