inline void APSizedArrayBase<_ElementType>::set_custom_memory_empty_unsafe(_ElementType ** custom_mem_pp, uint32_t allocated_count) { A_ASSERTX(!this->m_array_p || !custom_mem_pp, "Possible leak - if setting array_p to new value, must be previously null, or custom_mem_pp must be nullptr."); A_ASSERTX(this->m_count == 0, "As a safety precaution, the array must be empty before this function can be called, e.g. by calling empty() before this function."); this->m_array_p = custom_mem_pp; this->m_size = allocated_count; }
//--------------------------------------------------------------------------------------- // Modifiers: static // Author(s): Conan Reis ASymbolRef * ASymbolTable::symbol_reference(uint32_t sym_id, const char * cstr_p, uint32_t length, eATerm term) { if (sym_id == ASymbol_id_null) { #if defined(A_SYMBOL_REF_LINK) return ASymbol::ms_null.m_ref_p; #else return const_cast<ASymbolRef *>(&ASymbolRef::get_null()); #endif } // Ensure symbol string no larger than 255 characters since only 1-byte is used to store // length in binary. A_ASSERTX( length <= UINT8_MAX, AErrMsg( a_str_format( "Tried to create symbol '%s' (0x%X) but it too long!\n" "Its length is %u and the max length is 255 characters.\n" "[Try to use a different shorter string if possible.]", cstr_p, sym_id, length), AErrLevel_notify)); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Use existing symbol reference if it is already registered. uint32_t idx; ASymbolRef * sym_ref_p = m_sym_refs.get(sym_id, 1u, &idx); if (sym_ref_p) { // Found existing symbol reference // Check for name collision A_ASSERTX( sym_ref_p->m_str_ref_p->is_equal(cstr_p, length), AErrMsg( a_str_format( "Symbol id collision! The new string '%s' and the string '%s' are different,\n" "but they both have the same id 0x%X.\n" "[Try to use a different string if possible and hope that it has a unique id.]", cstr_p, sym_ref_p->m_str_ref_p->m_cstr_p, sym_id), AErrLevel_notify)); return sym_ref_p; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Create new symbol reference AStringRef * str_ref_p = (term == ATerm_long) ? AStringRef::pool_new(cstr_p, length, length + 1u, 1u, false, true) : AStringRef::pool_new_copy(cstr_p, length); sym_ref_p = ASymbolRef::pool_new(str_ref_p, sym_id); m_sym_refs.insert(*sym_ref_p, idx); return sym_ref_p; }