Crossfire Server, Trunk
sstring.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

sstring add_refcount (sstring str)
 
sstring add_string (const char *str)
 
int buf_overflow (const char *buf1, const char *buf2, size_t bufsize)
 
sstring find_string (const char *str)
 
void free_string (sstring str)
 
void init_hash_table (void)
 
int query_refcount (sstring str)
 
void ss_dump_statistics (char *buf, size_t size)
 
char * ss_dump_table (int what, char *buf, size_t size)
 

Variables

const typedef char * sstring
 

Function Documentation

◆ add_refcount()

◆ add_string()

sstring add_string ( const char *  str)

This will add 'str' to the hash table. If there's no entry for this string, a copy will be allocated, and a pointer to that is returned.

Parameters
strstring to share.
Returns
pointer to string identical to str, but shared.

Definition at line 124 of file shstr.cpp.

References shared_string::array, GATHER, hash_table, hashstr(), new_shared_string(), shared_string::next, shared_string::previous, shared_string::refcount, make_face_from_files::str, shared_string::string, TOPBIT, and shared_string::u.

Referenced by account_char_add(), account_char_load(), account_char_load_from_file(), account_play_cmd(), add_author(), add_book_to_list(), add_exit_to_item(), add_force(), ArchetypesWrapper::addArchetype(), QuestsWrapper::addQuest(), adjust_sign_msg(), alchemy_failure_effect(), animate_weapon(), apply_race_and_class(), asset_create(), become_follower(), cast_bless(), cast_create_town_portal(), cast_word_of_recall(), cctk_set_object_strings(), cfapi_system_add_string(), change_abil(), change_book(), change_treasure(), check_loaded_object(), check_login(), command_follow(), command_reset(), command_summon(), command_teleport(), command_unarmed_skill(), confuse_living(), create_singularity(), determine_god(), do_artifact(), do_each_skill(), do_goto(), do_magic(), do_map(), do_throw(), TreasureWrapper::doAddChild(), TreasureListWrapper::drop(), enter_player_savebed(), enter_random_map(), examine_monster(), find_or_create_connection_for_map(), fire_bow(), fix_container_multipart(), fix_generated_item(), fix_stopped_arrow(), generate_quest(), generate_random_list(), generate_random_map(), generate_random_treasure(), get_jail_exit(), get_npc(), get_player(), give_artifact_abilities(), god_enchants_weapon(), grant_immunity(), i18n(), i18n_init(), init_book_archive(), init_formulae(), init_globals(), key_change_class(), keyplace(), kill_player(), knowledge_add(), knowledge_read_player_data(), ArtifactLoader::load(), MessageLoader::load(), FaceLoader::load(), QuestLoader::load(), TreasureLoader::load(), load_map_header(), load_materials(), FaceLoader::loadAnimationBlock(), TreasureLoader::loadTreasure(), local_check_loaded_object(), lock_and_hide_doors(), monster_do_talk_npc(), move_marker(), new_text_name(), object_find_by_name(), object_find_by_name_global(), object_fix_multipart(), object_set_msg(), object_set_value(), object_set_value_s(), pets_summon_golem(), place_chest(), place_exits(), place_special_exit(), potion_type_apply(), process_map(), process_object(), quest_condition_from_string(), quest_create(), quest_read_player_data(), receive_play_again(), set_materialname(), TreasureWrapper::setArtifact(), QuestWrapper::setComment(), QuestStepWrapper::setDescription(), QuestWrapper::setDescription(), TreasureWrapper::setList(), QuestWrapper::setTitle(), START_TEST(), stringbuffer_finish_shared(), tailor_god_spell(), town_portal_find_force(), while(), and write_mark().

+ Here is the call graph for this function:

◆ buf_overflow()

int buf_overflow ( const char *  buf1,
const char *  buf2,
size_t  bufsize 
)

We don't want to exceed the buffer size of buf1 by adding on buf2!

Parameters
buf1
buf2buffers we plan on concatening. Can be NULL.
bufsizesize of buf1. Can be NULL.
Returns
true if overflow will occur.

Definition at line 398 of file shstr.cpp.

Referenced by book_overflow(), MessageLoader::load(), and START_TEST().

+ Here is the caller graph for this function:

◆ find_string()

sstring find_string ( const char *  str)

Searches a string in the shared strings.

Parameters
strstring to search for.
Returns
pointer to identical string or NULL

Definition at line 236 of file shstr.cpp.

References GATHER, hash_table, hashstr(), shared_string::next, make_face_from_files::str, and shared_string::string.

Referenced by cfapi_system_find_string(), find_artifact(), Archetypes::findByObjectName(), object_get_value(), object_set_value(), skill_throw(), and START_TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ free_string()

void free_string ( sstring  str)

This will reduce the refcount, and if it has reached 0, str will be freed.

Parameters
strstring to release, which *must *have been returned from a previous add_string().
Note
the memory pointed to by str can be freed after this call, so don't use str anymore.

Definition at line 280 of file shstr.cpp.

References shared_string::array, GATHER, shared_string::next, shared_string::previous, shared_string::refcount, SS, make_face_from_files::str, TOPBIT, and shared_string::u.

Referenced by account_char_add(), account_char_free(), account_char_remove(), add_abilities(), adjust_sign_msg(), alchemy_failure_effect(), animate_bomb(), animate_weapon(), apply_race_and_class(), asset_destroy(), become_follower(), cast_bless(), cast_change_ability(), cast_curse(), cfapi_system_remove_string(), change_abil(), change_book(), change_treasure(), check_loaded_object(), command_unarmed_skill(), cone_drop(), confuse_living(), create_aura(), do_symptoms(), do_throw(), dragon_focus_type_apply(), enter_player_savebed(), examine_monster(), fire_bow(), fix_container_multipart(), fix_object(), free_all_readable(), free_all_recipes(), free_arch(), free_artifact(), free_knowledge_items(), free_knowledge_player(), free_quest(), free_state(), give_artifact_abilities(), hit_with_arrow(), i18n(), i18n_free(), i18n_init(), identify(), infect_object(), key_change_class(), keyplace(), knowledge_god_add(), FaceLoader::load(), TreasureLoader::loadTreasure(), local_check_loaded_object(), make_formula_book(), mon_info_msg(), monster_communicate(), monster_move(), new_text_name(), object_copy_no_speed(), object_find_by_name(), object_find_by_name_global(), object_fix_multipart(), object_set_msg(), object_set_value(), pets_summon_golem(), poison_living(), potion_type_apply(), process_object(), quest_clear(), quest_destroy_condition(), AllAnimations::replace(), START_TEST(), tailor_god_spell(), town_portal_find_force(), and treasure_free().

◆ init_hash_table()

void init_hash_table ( void  )

Initialises the hash-table used by the shared string library.

Definition at line 55 of file shstr.cpp.

References hash_table, TABLESIZE, and nlohmann::detail::void().

Referenced by cctk_init_std_archetypes(), init_library(), and setup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ query_refcount()

int query_refcount ( sstring  str)

This will return the refcount of the string str.

Parameters
strstring which *must *have been returned from a previous add_string().
Returns
refcount of the string.

Definition at line 224 of file shstr.cpp.

References SS, make_face_from_files::str, and TOPBIT.

Referenced by START_TEST().

+ Here is the caller graph for this function:

◆ ss_dump_statistics()

void ss_dump_statistics ( char *  buf,
size_t  size 
)

A call to this function will cause the statistics to be dumped into specified buffer.

The routines will gather statistics if SS_STATISTICS is defined.

Parameters
bufbuffer which will contain dumped information.
sizebuf's size.

Definition at line 323 of file shstr.cpp.

References buf, and is_valid_types_gen::line.

Referenced by command_strings().

+ Here is the caller graph for this function:

◆ ss_dump_table()

char* ss_dump_table ( int  what,
char *  buf,
size_t  size 
)

Dump the contents of the share string tables.

Parameters
whatcombination of flags:
  • SS_DUMP_TABLE: dump the contents of the hash table to stderr.
  • SS_DUMP_TOTALS: return a string which says how many entries etc. there are in the table.
bufbuffer that will contain total information if (what & SS_DUMP_TABLE). Left untouched else.
sizebuffer's size
Returns
buf if (what & SS_DUMP_TOTALS) or NULL.

Definition at line 354 of file shstr.cpp.

References buf, hash_table, llevDebug, LOG(), shared_string::next, shared_string::refcount, SS_DUMP_TABLE, SS_DUMP_TOTALS, shared_string::string, TABLESIZE, and TOPBIT.

Referenced by command_ssdumptable(), and command_strings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ sstring

const typedef char* sstring

Definition at line 2 of file sstring.h.

Referenced by add_abilities(), add_object_to_socklist(), add_one_item(), adjust_sign_msg(), append_spell(), apply_check_race_restrictions(), ResourcesManager::archetypeUse(), cf_add_string(), cf_archetype_get_name(), cf_find_string(), cf_map_get_sstring_property(), cf_object_get_msg(), cf_object_get_sstring_property(), cf_party_get_name(), cf_party_get_password(), cf_player_get_ip(), cf_query_name_pl(), cf_region_get_jail_path(), cf_region_get_longname(), cf_region_get_message(), cf_region_get_name(), cfapi_archetype_get_property(), cfapi_generate_random_map(), cfapi_map_get_map_property(), cfapi_object_get_property(), cfapi_party_get_property(), cfapi_player_quest(), cfapi_region_get_property(), cfapi_system_add_string(), cfapi_system_find_string(), cfapi_system_remove_string(), change_book(), command_cast_spell(), command_rename_item(), command_reset(), compilePython(), do_harvest(), esrv_add_spells(), esrv_update_item(), examine(), find_artifact(), i18n(), i18n_init(), initapplyobject(), initdropobject(), initpickupobject(), knowledge_read(), mon_info_msg(), monster_move_randomly(), move_aura(), object_give_identified_properties(), object_handle_death_animation(), object_matches_string(), CREMainWindow::onReportDuplicate(), play_sound_player_only(), Player_QuestGetState(), Player_QuestSetState(), Player_QuestStart(), Player_QuestWasCompleted(), process_object(), reportSummon(), runapplyobject(), rundropobject(), runpickupobject(), scroll_type_apply(), set_object_face_main(), set_object_face_other(), SP_level_wc_adjust(), spell_consume_items(), START_TEST(), stringbuffer_finish_shared(), and ArchetypeWrapper::uses().