void add_error_handler(ErrorHandlerList *p_handler) { _global_lock(); p_handler->next = error_handler_list; error_handler_list = p_handler; _global_unlock(); }
void StringName::unref() { ERR_FAIL_COND(!configured); if (_data && _data->refcount.unref()) { _global_lock(); if (_data->prev) { _data->prev->next=_data->next; } else { if (_table[_data->idx]!=_data) { ERR_PRINT("BUG!"); } _table[_data->idx]=_data->next; } if (_data->next) { _data->next->prev=_data->prev; } memdelete(_data); _global_unlock(); } _data=NULL; }
void remove_error_handler(ErrorHandlerList *p_handler) { _global_lock(); ErrorHandlerList *prev = NULL; ErrorHandlerList *l = error_handler_list; while(l) { if (l==p_handler) { if (prev) prev->next=l->next; else error_handler_list=l->next; break; } prev=l; l=l->next; } _global_unlock(); }
StringName StringName::search(const String &p_name) { ERR_FAIL_COND_V( p_name=="", StringName() ); _global_lock(); uint32_t hash = p_name.hash(); uint32_t idx=hash&STRING_TABLE_MASK; _Data *_data=_table[idx]; while(_data) { // compare hash first if (_data->hash==hash && p_name==_data->get_name()) break; _data=_data->next; } if (_data && _data->refcount.ref()) { _global_unlock(); return StringName(_data); } _global_unlock(); return StringName(); //does not exist }
void StringName::cleanup() { _global_lock(); int lost_strings=0; for(int i=0;i<STRING_TABLE_LEN;i++) { while(_table[i]) { _Data*d=_table[i]; lost_strings++; if (OS::get_singleton()->is_stdout_verbose()) { if (d->cname) { print_line("Orphan StringName: "+String(d->cname)); } else { print_line("Orphan StringName: "+String(d->name)); } } _table[i]=_table[i]->next; memdelete(d); } } if (OS::get_singleton()->is_stdout_verbose() && lost_strings) { print_line("StringName: "+itos(lost_strings)+" unclaimed string names at exit."); } _global_unlock(); }
void remove_print_handler(PrintHandlerList *p_handler) { OS::get_singleton()->print("pre-removing print handler...\n"); _global_lock(); PrintHandlerList *prev = NULL; PrintHandlerList *l = print_handler_list; OS::get_singleton()->print("removing print handler...\n"); while(l) { if (l==p_handler) { OS::get_singleton()->print("found\n"); if (prev) prev->next=l->next; else print_handler_list=l->next; break; } prev=l; l=l->next; } OS::get_singleton()->print("print hanlder list is %p\n",print_handler_list); ERR_FAIL_COND(l==NULL); _global_unlock(); }
StringName StringName::search(const CharType *p_name) { ERR_FAIL_COND_V(!configured,StringName()); ERR_FAIL_COND_V( !p_name, StringName() ); if (!p_name[0]) return StringName(); _global_lock(); uint32_t hash = String::hash(p_name); uint32_t idx=hash&STRING_TABLE_MASK; _Data *_data=_table[idx]; while(_data) { // compare hash first if (_data->hash==hash && _data->get_name()==p_name) break; _data=_data->next; } if (_data && _data->refcount.ref()) { _global_unlock(); return StringName(_data); } _global_unlock(); return StringName(); //does not exist }
void add_print_handler(PrintHandlerList *p_handler) { _global_lock(); p_handler->next=print_handler_list; print_handler_list=p_handler; _global_unlock(); }
StringName::StringName(const String& p_name) { _data=NULL; ERR_FAIL_COND(!configured); if (p_name==String()) return; _global_lock(); uint32_t hash = p_name.hash(); uint32_t idx=hash&STRING_TABLE_MASK; _data=_table[idx]; while(_data) { if (_data->hash==hash && _data->get_name()==p_name) break; _data=_data->next; } if (_data) { if (_data->refcount.ref()) { // exists _global_unlock(); return; } else { } } _data = memnew( _Data ); _data->name=p_name; _data->refcount.init(); _data->hash=hash; _data->idx=idx; _data->cname=NULL; _data->next=_table[idx]; _data->prev=NULL; if (_table[idx]) _table[idx]->prev=_data; _table[idx]=_data; _global_unlock(); }
StringName::StringName(const char *p_name) { _data=NULL; ERR_FAIL_COND(!configured); if (!p_name || p_name[0]==0) return; //empty, ignore _global_lock(); uint32_t hash = String::hash(p_name); uint32_t idx=hash&STRING_TABLE_MASK; _data=_table[idx]; while(_data) { // compare hash first if (_data->hash==hash && _data->get_name()==p_name) break; _data=_data->next; } if (_data) { if (_data->refcount.ref()) { // exists _global_unlock(); return; } else { } } _data = memnew( _Data ); _data->name=p_name; _data->refcount.init(); _data->hash=hash; _data->idx=idx; _data->cname=NULL; _data->next=_table[idx]; _data->prev=NULL; if (_table[idx]) _table[idx]->prev=_data; _table[idx]=_data; _global_unlock(); }
StringName::StringName(const StaticCString& p_static_string) { _data=NULL; ERR_FAIL_COND(!configured); ERR_FAIL_COND( !p_static_string.ptr || !p_static_string.ptr[0]); _global_lock(); uint32_t hash = String::hash(p_static_string.ptr); uint32_t idx=hash&STRING_TABLE_MASK; _data=_table[idx]; while(_data) { // compare hash first if (_data->hash==hash && _data->get_name()==p_static_string.ptr) break; _data=_data->next; } if (_data) { if (_data->refcount.ref()) { // exists _global_unlock(); return; } else { } } _data = memnew( _Data ); _data->refcount.init(); _data->hash=hash; _data->idx=idx; _data->cname=p_static_string.ptr; _data->next=_table[idx]; _data->prev=NULL; if (_table[idx]) _table[idx]->prev=_data; _table[idx]=_data; _global_unlock(); }
void print_line(String p_string) { OS::get_singleton()->print("%s\n",p_string.utf8().get_data()); _global_lock(); PrintHandlerList *l = print_handler_list; while(l) { l->printfunc(l->userdata,p_string); l=l->next; } _global_unlock(); }
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, ErrorHandlerType p_type) { OS::get_singleton()->print_error(p_function, p_file, p_line, p_error, _err_error_exists ? OS::get_singleton()->get_last_error() : "", (Logger::ErrorType)p_type); _global_lock(); ErrorHandlerList *l = error_handler_list; while (l) { l->errfunc(l->userdata, p_function, p_file, p_line, p_error, _err_error_exists ? OS::get_singleton()->get_last_error() : "", p_type); l = l->next; } _global_unlock(); if (_err_error_exists) { OS::get_singleton()->clear_last_error(); _err_error_exists = false; } }