35 #define MAX_NUMBER 1000000000
55 if (base_name_len + number_str_len >=
MAX_NAME) {
56 base_name_len =
MAX_NAME - number_str_len - 1;
61 base_name[base_name_len] =
'\0';
68 name[base_name_len] =
'\0';
73 BLI_strncpy(name + base_name_len, number_str, number_str_len + 1);
100 static constexpr
unsigned max_exact_tracking = 1024;
106 if (number >= 0 && number < max_exact_tracking) {
116 if (number >= 0 && number < max_exact_tracking) {
119 if (number > 0 && number == max_value) {
126 if (number >= 0 && number < max_exact_tracking) {
152 mask[0] |= prev_first & 1;
172 return index >= 0 ? &type_maps[index] :
nullptr;
184 #ifdef DEBUG_PRINT_MEMORY_USAGE
192 "NameMap memory usage: sets %.1fKB, maps %.1fKB\n", size_sets / 1024.0, size_maps / 1024.0);
194 MEM_delete<UniqueName_Map>(*r_name_map);
195 *r_name_map =
nullptr;
200 BLI_assert_msg(name_map !=
nullptr,
"name_map should not be null");
234 if (
id->
lib !=
nullptr) {
239 return id->lib->runtime.name_map;
241 if (ensure_created && bmain->
name_map ==
nullptr) {
260 bool is_name_changed =
false;
272 bool added_new =
false;
277 if (added_new || !has_dup) {
288 return is_name_changed;
292 int number_to_use = -1;
295 number_to_use = number;
302 if (number_to_use == -1) {
305 number_to_use = number;
328 is_name_changed =
true;
330 return is_name_changed;
341 if (name[0] ==
'\0') {
346 if (name_map ==
nullptr) {
361 if (val ==
nullptr) {
364 if (number == 0 && val->
max_value == 0) {
395 key.
lib = id_iter->lib;
396 if (!id_names_libs.
add(key)) {
399 "ID name '%s' (from library '%s') is found more than once",
401 id_iter->lib !=
nullptr ? id_iter->lib->filepath :
"<None>");
406 bmain,
which_libbase(bmain,
GS(id_iter->name)), id_iter,
nullptr,
true);
408 if (!id_names_libs.
add(key)) {
410 "\tID has been renamed to '%s', but it still seems to be already in use",
414 CLOG_WARN(&
LOG,
"\tID has been renamed to '%s'", id_iter->name);
420 if (name_map ==
nullptr) {
432 "ID name '%s' (from library '%s') exists in current Main, but is not listed in "
435 id_iter->lib !=
nullptr ? id_iter->lib->filepath :
"<None>");
444 if (name_map !=
nullptr) {
449 if (type_map !=
nullptr) {
452 *(
reinterpret_cast<short *
>(key.
name)) = idcode;
458 "ID name '%s' (from library '%s') is listed in the namemap, but does not "
459 "exists in current Main",
461 lib !=
nullptr ?
lib->filepath :
"<None>");
468 name_map = (
lib !=
nullptr) ?
lib->runtime.name_map :
nullptr;
469 }
while (
lib !=
nullptr);
480 if (*name_map_p !=
nullptr) {
484 name_map_p = (
lib !=
nullptr) ? &
lib->runtime.name_map :
nullptr;
485 }
while (
lib !=
nullptr);
short BKE_idtype_idcode_iter_step(int *index)
int BKE_idtype_idcode_to_index(short idcode)
bool BKE_id_new_name_validate(struct Main *bmain, struct ListBase *lb, struct ID *id, const char *name, bool do_linked_data) ATTR_NONNULL(1
#define FOREACH_MAIN_ID_END
#define FOREACH_MAIN_LISTBASE_END
#define FOREACH_MAIN_LISTBASE_BEGIN(_bmain, _lb)
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id)
struct ListBase * which_libbase(struct Main *bmain, short type)
#define BLI_assert_msg(a, msg)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
#define BLI_BITMAP_DISABLE(_bitmap, _index)
int BLI_bitmap_find_first_unset(const BLI_bitmap *bitmap, size_t bits)
#define BLI_BITMAP_TEST_BOOL(_bitmap, _index)
bool BLI_ghashutil_strcmp(const void *a, const void *b)
size_t BLI_ghashutil_combine_hash(size_t hash_a, size_t hash_b)
unsigned int BLI_ghashutil_strhash_n(const char *key, size_t n)
unsigned int BLI_ghashutil_ptrhash(const void *key)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
size_t BLI_snprintf_rlen(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
int BLI_str_utf8_invalid_strip(char *str, size_t length) ATTR_NONNULL(1)
size_t BLI_split_name_num(char *left, int *nr, const char *name, char delim)
#define CLOG_ERROR(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
ID and Library types, which are fundamental for sdna.
Read Guarded memory(de)allocation.
int64_t size_in_bytes() const
Value & lookup_or_add_cb(const Key &key, const CreateValueF &create_value)
Value & lookup_or_add_default(const Key &key)
bool remove(const Key &key)
const Value * lookup_ptr(const Key &key) const
int64_t size_in_bytes() const
bool contains(const Key &key) const
bool remove(const Key &key)
std::string id_name(void *id)
bool BKE_main_namemap_validate_and_fix(Main *bmain)
static UniqueName_Map * get_namemap_for(Main *bmain, ID *id, bool ensure_created)
void BKE_main_namemap_remove_name(struct Main *bmain, struct ID *id, const char *name)
static bool id_name_final_build(char *name, char *base_name, size_t base_name_len, int number)
bool BKE_main_namemap_get_name(struct Main *bmain, struct ID *id, char *name)
bool BKE_main_namemap_validate(Main *bmain)
void BKE_main_namemap_destroy(struct UniqueName_Map **r_name_map)
static bool main_namemap_validate_and_fix(Main *bmain, const bool do_fix)
static void main_namemap_populate(UniqueName_Map *name_map, struct Main *bmain, ID *ignore_id)
struct UniqueName_Map * BKE_main_namemap_create()
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
void max_inplace(T &a, const T &b)
SocketIndexByIdentifierMap * map
unsigned __int64 uint64_t
struct UniqueName_Map * name_map
struct Library_Runtime runtime
struct UniqueName_Map * name_map
bool operator==(const UniqueName_Key &o) const
UniqueName_TypeMap * find_by_type(short id_type)
UniqueName_TypeMap type_maps[INDEX_ID_MAX]
Set< UniqueName_Key > full_names
Map< UniqueName_Key, UniqueName_Value > base_name_to_num_suffix
int use_smallest_unused()
void mark_used(int number)
BLI_BITMAP_DECLARE(mask, max_exact_tracking)
void mark_unused(int number)
bool use_if_unused(int number)
bool operator==(const Uniqueness_Key &o) const
static FT_Library library