/** * librdf_world_init_mutex: * @world: redland world object * * INTERNAL - Create the world mutex. */ void librdf_world_init_mutex(librdf_world* world) { #ifdef WITH_THREADS world->mutex = (pthread_mutex_t *) SYSTEM_MALLOC(sizeof(pthread_mutex_t)); pthread_mutex_init(world->mutex, NULL); world->nodes_mutex = (pthread_mutex_t *) SYSTEM_MALLOC(sizeof(pthread_mutex_t)); pthread_mutex_init(world->nodes_mutex, NULL); world->statements_mutex = (pthread_mutex_t *) SYSTEM_MALLOC(sizeof(pthread_mutex_t)); pthread_mutex_init(world->statements_mutex, NULL); world->hash_datums_mutex = (pthread_mutex_t *) SYSTEM_MALLOC(sizeof(pthread_mutex_t)); pthread_mutex_init(world->hash_datums_mutex, NULL); #else #endif }
void * fail_prone_malloc(malloc_zone_t *zone, size_t size) { return drand48() < ALLOC_ERR_PROB ? NULL : SYSTEM_MALLOC(zone, size); }
void * fail_countdown_malloc(malloc_zone_t *zone, size_t size) { if (ALLOC_FAIL_COUNTER >= 0) ALLOC_FAIL_COUNTER--; return ALLOC_FAIL_COUNTER < 0 ? NULL : SYSTEM_MALLOC(zone, size); }