void * __om_malloc_debug(uint32 length, const char *file, const int line) { void * toret = NULL; if( om_malloc_fail==OM_TRUE ) { return NULL; } else { toret = __om_malloc_regular(length); if( ! om_malloc_tracking && toret!=NULL ) { om_malloc_tracking = OM_TRUE; if( om_mallocs == NULL ) { om_mallocs = om_dict_new(40); ((om_dict_ptr)om_mallocs)->release_func=__om_malloc_debug_release_func; ((om_dict_ptr)om_mallocs)->hash_func=__om_malloc_debug_hash_func; } om_dict_put( om_mallocs, toret, om_string_format("%i:%s",line,file) ); //printf("adding %8X %s\n",toret,om_dict_get(om_mallocs,toret)); om_malloc_count++; om_malloc_tracking = OM_FALSE; } } return toret; }
om_dict_ptr om_dict_from_query_string(const char *queryString) { om_list_ptr keyValPairs = om_string_explode(queryString,'&'); om_dict_ptr ret = om_dict_new(5); ret->release_func=om_dict_release_default_func; int c = om_list_count(keyValPairs); for( int i=0; i<c; i++ ) { char * val = om_list_get(keyValPairs,i); om_list_ptr keyVal = om_string_explode( val, '=' ); if( om_list_count(keyVal)==2 ) { om_dict_put( ret, om_string_copy(om_list_get(keyVal,0)), om_string_copy(om_list_get(keyVal,1)) ); } else if( om_list_count(keyVal)==1 ) { om_dict_put( ret, om_string_copy(om_list_get(keyVal,0)), "" ); } om_list_release(keyVal); } om_list_release(keyValPairs); return ret; }
om_bool om_mock_prefs_set(const om_prefs_ptr prefs, const char *key, const char *value) { // the device implementation will have to copy these return om_dict_put((om_prefs_ptr)prefs->device_data,om_string_copy(key),om_string_copy(value))!=OM_NULL ? OM_TRUE : OM_FALSE; }