static int time_it(cfuhash_function_t hf, double *elapsed_time, u_int32_t num_tests) { cfuhash_table_t *hash = cfuhash_new_with_initial_size(30); u_int32_t flags = 0; char key[32]; char value[32]; size_t i; size_t used; size_t num_buckets; size_t num_entries; cfutime_t *time = cfutime_new(); /* freeze the hash so that it won't shrink while we put in all the data */ flags = cfuhash_set_flag(hash, CFUHASH_FROZEN_UNTIL_GROWS); cfuhash_set_hash_function(hash, hf); cfutime_begin(time); for (i = 0; i < num_tests; i++) { sprintf(key, "%u", 15000000 - i); sprintf(value, "value%d", i); cfuhash_put(hash, key, dup_str(value)); } cfutime_end(time); *elapsed_time = cfutime_elapsed(time); used = cfuhash_num_buckets_used(hash); num_buckets = cfuhash_num_buckets(hash); num_entries = cfuhash_num_entries(hash); printf("%d entries, %d/%d buckets (%.2f%%), %.2f%% threshold check\n", num_entries, used, num_buckets, 100.0 * (float)used/(float)num_buckets, 100.0 * (float)num_entries/(float)num_buckets); cfuhash_destroy_with_free_fn(hash, free_data); return 0; }
void FuseSDKShowAdForZoneID_platform(const char* zoneID, cfuhash_table_t* options) { // parse out the options here and pass them to Java bool showPre = true; bool showPost = true; const char* yesText = NULL; const char* noText = NULL; const char* continueText = NULL; int numOptions = cfuhash_num_entries(options); if( numOptions > 0 ) { char* key = NULL; void* data = NULL; if( cfuhash_each(options, &key,&data) ) { do { if( strcmp(key, kFuseSDKRewardedAdOptionKey_ShowPreRoll) == 0 ) { if( strcmp((const char*)data, "0") == 0 || strcmp((const char*)data, "false") == 0 ) { showPre = false; } } else if( strcmp(key, kFuseSDKRewardedAdOptionKey_ShowPostRoll) == 0 ) { if( strcmp((const char*)data, "0") == 0 || strcmp((const char*)data, "false") == 0 ) { showPost = false; } } else if( strcmp(key, kFuseSDKRewardedOptionKey_PreRollYesButtonText) == 0 ) { yesText = (const char*)data; } else if( strcmp(key, kFuseSDKRewardedOptionKey_PreRollNoButtonText) == 0 ) { noText = (const char*)data; } else if( strcmp(key, kFuseSDKRewardedOptionKey_PostRollContinueButtonText) == 0 ) { continueText = (const char*)data; } } while( cfuhash_next(options, &key, &data) ); } } JNIEnv* env = s3eEdkJNIGetEnv(); jstring zoneID_jstr = env->NewStringUTF(zoneID); jstring yesText_jstr = env->NewStringUTF(yesText); jstring noText_jstr = env->NewStringUTF(noText); jstring continueText_jstr = env->NewStringUTF(continueText); env->CallVoidMethod(g_Obj, g_FuseSDKShowAdForZoneID, zoneID_jstr, showPre, showPost, yesText_jstr, noText_jstr, continueText_jstr); }