From 67f1740feaff7979d64749b2a2755e909579ae96 Mon Sep 17 00:00:00 2001 From: alexpeshkoff Date: Sun, 14 Mar 2004 13:40:14 +0000 Subject: [PATCH] Various cleanup to make engine compile and work after mentioned earlier changes. Mainly: 1) MemoryPool* => MemoryPool& in arrays' constructors 2) use Firebird::string to keep strings data --- src/common/classes/locks.h | 4 ++-- src/dsql/pass1.cpp | 5 +++-- src/include/fb_vector.h | 4 ++-- src/jrd/btr.cpp | 14 ++++++------ src/jrd/cch.cpp | 5 ++--- src/jrd/cmp.cpp | 6 ++--- src/jrd/common.h | 12 +--------- src/jrd/db_alias.cpp | 19 ++++++++-------- src/jrd/db_alias.h | 2 +- src/jrd/dfw.epp | 19 ++++++++-------- src/jrd/dls.cpp | 5 ++--- src/jrd/dyn_def.epp | 22 +++++++++---------- src/jrd/err.cpp | 16 ++++---------- src/jrd/evl_string.h | 16 +++++++------- src/jrd/exe.cpp | 2 +- src/jrd/exe.h | 8 +++---- src/jrd/execute_statement.cpp | 3 ++- src/jrd/execute_statement.h | 1 - src/jrd/ext.cpp | 41 +++++++++++++++++++++-------------- src/jrd/flu.cpp | 30 +++++++++++++++++-------- src/jrd/gds.cpp | 2 -- src/jrd/inf.cpp | 6 ++--- src/jrd/ini.epp | 2 +- src/jrd/jrd_proto.h | 19 +++++++++++++++- src/jrd/nbak.cpp | 4 ++-- src/jrd/opt.cpp | 24 ++++++++++---------- src/jrd/os/win32/winnt.cpp | 6 ++--- src/jrd/req.h | 2 +- src/jrd/rse.cpp | 6 ++--- src/jrd/rse.h | 2 +- src/jrd/shut.cpp | 2 +- src/jrd/tra.cpp | 7 +++--- src/jrd/val.cpp | 2 +- src/jrd/vio.cpp | 3 +-- src/remote/interface.cpp | 17 +++++---------- src/utilities/gstat/dba.epp | 7 +++--- 36 files changed, 178 insertions(+), 167 deletions(-) diff --git a/src/common/classes/locks.h b/src/common/classes/locks.h index cda50d0092..ee076366e9 100644 --- a/src/common/classes/locks.h +++ b/src/common/classes/locks.h @@ -32,7 +32,7 @@ * Contributor(s): * * - * $Id: locks.h,v 1.11 2004-03-07 07:58:25 robocop Exp $ + * $Id: locks.h,v 1.12 2004-03-14 13:40:09 alexpeshkoff Exp $ * */ @@ -179,6 +179,6 @@ public: #endif /* MULTI_THREAD */ -} +} //namespace Firebird #endif // CLASSES_LOCKS_H diff --git a/src/dsql/pass1.cpp b/src/dsql/pass1.cpp index 84f4b8a779..3be8c83ba7 100644 --- a/src/dsql/pass1.cpp +++ b/src/dsql/pass1.cpp @@ -174,7 +174,8 @@ public: } }; -typedef Firebird::SortedArray, const char*, Firebird::DefaultKeyValue, CStrCmp> StrArray; @@ -1254,7 +1255,7 @@ dsql_nod* PASS1_statement(dsql_req* request, dsql_nod* input, bool proc_flag) node->nod_arg[e_exe_blk_body] = input->nod_arg[e_exe_blk_body]; { - StrArray names( getDefaultMemoryPool(), + StrArray names( *getDefaultMemoryPool(), node->nod_arg[e_exe_blk_inputs] ? node->nod_arg[e_exe_blk_inputs]->nod_count : 0 + node->nod_arg[e_exe_blk_outputs] ? diff --git a/src/include/fb_vector.h b/src/include/fb_vector.h index b795c6dd38..d9e0b8129d 100644 --- a/src/include/fb_vector.h +++ b/src/include/fb_vector.h @@ -22,10 +22,10 @@ namespace Firebird { public: vector(int len) : std::vector >(len) {} - vector(int len, MemoryPool &p, SSHORT type = 0) + vector(int len, MemoryPool& p, SSHORT type = 0) : std::vector >(len, T(), Firebird::allocator(p, type)) {} - vector(MemoryPool &p, SSHORT type = 0) + vector(MemoryPool& p, SSHORT type = 0) : std::vector >( Firebird::allocator(p, type) ) {} }; diff --git a/src/jrd/btr.cpp b/src/jrd/btr.cpp index 9e7fe62f6a..a0f52984ad 100644 --- a/src/jrd/btr.cpp +++ b/src/jrd/btr.cpp @@ -1542,7 +1542,7 @@ void BTR_selectivity(thread_db* tdbb, jrd_rel* relation, USHORT id, SelectivityL const USHORT segments = root->irt_rpt[id].irt_keys; SSHORT count, stuff_count, pos, i; - Firebird::HalfStaticArray duplicatesList(tdbb->tdbb_default); + Firebird::HalfStaticArray duplicatesList(*tdbb->tdbb_default); duplicatesList.grow(segments); memset(duplicatesList.begin(), 0, segments * sizeof(ULONG)); @@ -2311,7 +2311,7 @@ static CONTENTS delete_node(thread_db* tdbb, WIN *window, UCHAR *pointer) // remove jump nodes pointing to the deleted node or node // next to the deleted one. jumpNodeList* jumpNodes = FB_NEW(*tdbb->tdbb_default) - jumpNodeList(tdbb->tdbb_default); + jumpNodeList(*tdbb->tdbb_default); IndexJumpInfo jumpInfo; pointer = BTreeNode::getPointerFirstNode(page, &jumpInfo); @@ -2562,7 +2562,7 @@ static SLONG fast_load(thread_db* tdbb, typedef Firebird::vector jumpNodeListContainer; jumpNodeListContainer* jumpNodes = FB_NEW(*tdbb->tdbb_default) jumpNodeListContainer(*tdbb->tdbb_default); - jumpNodes->push_back(FB_NEW(*tdbb->tdbb_default) jumpNodeList(tdbb->tdbb_default)); + jumpNodes->push_back(FB_NEW(*tdbb->tdbb_default) jumpNodeList(*tdbb->tdbb_default)); keyList* jumpKeys = FB_NEW(*tdbb->tdbb_default) keyList(*tdbb->tdbb_default); jumpKeys->push_back(FB_NEW(*tdbb->tdbb_default) dynKey); @@ -2652,7 +2652,7 @@ static SLONG fast_load(thread_db* tdbb, ULONG duplicates = 0; const USHORT segments = idx->idx_count; SSHORT segment, stuff_count, pos, i; - Firebird::HalfStaticArray duplicatesList(tdbb->tdbb_default); + Firebird::HalfStaticArray duplicatesList(*tdbb->tdbb_default); duplicatesList.grow(segments); memset(duplicatesList.begin(), 0, segments * sizeof(ULONG)); @@ -2979,7 +2979,7 @@ static SLONG fast_load(thread_db* tdbb, // Initialize jumpNodes variables for new level jumpNodes->push_back(FB_NEW(*tdbb->tdbb_default) - jumpNodeList(tdbb->tdbb_default)); + jumpNodeList(*tdbb->tdbb_default)); jumpKeys->push_back(FB_NEW(*tdbb->tdbb_default) dynKey); (*jumpKeys)[level]->keyLength = 0; (*jumpKeys)[level]->keyData = @@ -4392,7 +4392,7 @@ static CONTENTS garbage_collect(thread_db* tdbb, WIN * window, SLONG parent_numb newBucket->btr_length += l; // Generate new jump nodes. - jumpNodeList* jumpNodes = FB_NEW(*tdbb->tdbb_default) jumpNodeList(tdbb->tdbb_default); + jumpNodeList* jumpNodes = FB_NEW(*tdbb->tdbb_default) jumpNodeList(*tdbb->tdbb_default); USHORT jumpersNewSize = 0; // Update jump information on scratch page, so generate_jump_nodes // can deal with it. @@ -4971,7 +4971,7 @@ static SLONG insert_node(thread_db* tdbb, USHORT newPrefixTotalBySplit = 0; USHORT splitJumpNodeIndex = 0; IndexJumpInfo jumpInfo; - jumpNodeList* jumpNodes = FB_NEW(*tdbb->tdbb_default) jumpNodeList(tdbb->tdbb_default); + jumpNodeList* jumpNodes = FB_NEW(*tdbb->tdbb_default) jumpNodeList(*tdbb->tdbb_default); USHORT ensureEndInsert = 0; if (endOfPage) { diff --git a/src/jrd/cch.cpp b/src/jrd/cch.cpp index 2008599817..b743ebd05f 100644 --- a/src/jrd/cch.cpp +++ b/src/jrd/cch.cpp @@ -1686,7 +1686,7 @@ void CCH_init(thread_db* tdbb, ULONG number) if (count != (SLONG) bcb_->bcb_count) { gds__log ("Database: %s\n\tAllocated %ld page buffers of %ld requested", - tdbb->tdbb_attachment->att_filename->str_data, bcb_->bcb_count, count); + tdbb->tdbb_attachment->att_filename.c_str(), bcb_->bcb_count, count); } if (dbb->dbb_lock->lck_logical != LCK_EX) { @@ -3243,8 +3243,7 @@ static void THREAD_ROUTINE cache_writer(Database* dbb) tdbb->tdbb_default = dbb->dbb_bufferpool; tdbb->tdbb_status_vector = status_vector; tdbb->tdbb_quantum = QUANTUM; - tdbb->tdbb_attachment = FB_NEW(*dbb->dbb_bufferpool) att; - tdbb->tdbb_attachment->att_database = dbb; + tdbb->tdbb_attachment = FB_NEW(*dbb->dbb_bufferpool) att(dbb); tdbb->tdbb_attachment->att_filename = dbb->dbb_filename; /* This try block is specifically to protect the LCK_init call: if diff --git a/src/jrd/cmp.cpp b/src/jrd/cmp.cpp index 77e682d1ff..81e67f6a32 100644 --- a/src/jrd/cmp.cpp +++ b/src/jrd/cmp.cpp @@ -1843,7 +1843,7 @@ jrd_req* CMP_make_request(thread_db* tdbb, Csb* csb) MsgInvariantArray* msg_invariants; if (!msg->nod_arg[e_msg_invariants]) { msg_invariants = FB_NEW(*tdbb->tdbb_default) - MsgInvariantArray(tdbb->tdbb_default); + MsgInvariantArray(*tdbb->tdbb_default); msg->nod_arg[e_msg_invariants] = reinterpret_cast(msg_invariants); } @@ -1866,7 +1866,7 @@ jrd_req* CMP_make_request(thread_db* tdbb, Csb* csb) if (!(*var_invariants)) { *var_invariants = FB_NEW(*tdbb->tdbb_default) - VarInvariantArray(tdbb->tdbb_default); + VarInvariantArray(*tdbb->tdbb_default); } int pos; if (!(*var_invariants)->find((*link_ptr)->nod_impure, pos)) @@ -3174,7 +3174,7 @@ static jrd_nod* pass1(thread_db* tdbb, { (*i_node)->nod_variables = FB_NEW(*tdbb->tdbb_default) - Firebird::Array(tdbb->tdbb_default); + Firebird::Array(*tdbb->tdbb_default); } (*i_node)->nod_variables->add(node); } diff --git a/src/jrd/common.h b/src/jrd/common.h index 76e28c6181..377bf9aabc 100644 --- a/src/jrd/common.h +++ b/src/jrd/common.h @@ -49,7 +49,7 @@ * */ /* -$Id: common.h,v 1.108 2004-03-12 07:00:46 skidder Exp $ +$Id: common.h,v 1.109 2004-03-14 13:39:44 alexpeshkoff Exp $ */ #ifndef JRD_COMMON_H @@ -1088,16 +1088,6 @@ inline int fb_stricmp(const char* a, const char* b) #ifdef HAVE_UNISTD_H #include #endif -inline char* fb_getcwd(char* output_buf, size_t len) -{ -#if defined(WIN_NT) - return _getcwd(output_buf, len); -#elif defined(HAVE_GETCWD) - return getcwd(output_buf, len); -#else - return getwd(output_buf); -#endif -} #endif /* JRD_COMMON_H */ diff --git a/src/jrd/db_alias.cpp b/src/jrd/db_alias.cpp index bd8ea0559a..0c4f401790 100644 --- a/src/jrd/db_alias.cpp +++ b/src/jrd/db_alias.cpp @@ -27,16 +27,15 @@ #include "../common/config/config.h" #include "../common/config/config_file.h" #include "../jrd/os/path_utils.h" -#include "../jrd/gds_proto.h" typedef Firebird::PathName string; const char* ALIAS_FILE = "aliases.conf"; -bool ResolveDatabaseAlias(const char* alias, char* database) +bool ResolveDatabaseAlias(const string& alias, string& database) { - TEXT alias_filename[MAXPATHLEN]; - gds__prefix(alias_filename, const_cast(ALIAS_FILE)); + string alias_filename; + Firebird::Prefix(alias_filename, ALIAS_FILE); ConfigFile aliasConfig(false); aliasConfig.setConfigFile(alias_filename); @@ -45,17 +44,17 @@ bool ResolveDatabaseAlias(const char* alias, char* database) string corrected_alias = alias; std::replace(corrected_alias.begin(), corrected_alias.end(), incorrect_dir_sep, correct_dir_sep); - string value = aliasConfig.getString(corrected_alias); + database = aliasConfig.getString(corrected_alias); - if (!value.empty()) + if (!database.empty()) { - std::replace(value.begin(), value.end(), incorrect_dir_sep, correct_dir_sep); - if (PathUtils::isRelative(value)) { + std::replace(database.begin(), database.end(), incorrect_dir_sep, correct_dir_sep); + if (PathUtils::isRelative(database)) { gds__log("Value %s configured for alias %s " - "is not a fully qualified path name, ignored", value.c_str(), alias); + "is not a fully qualified path name, ignored", + database.c_str(), alias.c_str()); return false; } - strcpy(database, value.c_str()); return true; } diff --git a/src/jrd/db_alias.h b/src/jrd/db_alias.h index 24399ab142..f745f5cec4 100644 --- a/src/jrd/db_alias.h +++ b/src/jrd/db_alias.h @@ -22,5 +22,5 @@ #ifndef DB_ALIAS_H #define DB_ALIAS_H -bool ResolveDatabaseAlias(const char* alias, char* database); +bool ResolveDatabaseAlias(const Firebird::PathName& alias, Firebird::PathName& database); #endif diff --git a/src/jrd/dfw.epp b/src/jrd/dfw.epp index fa9c73bd5e..093e9b4770 100644 --- a/src/jrd/dfw.epp +++ b/src/jrd/dfw.epp @@ -49,6 +49,7 @@ */ #include "firebird.h" +#include "fb_string.h" #include "../jrd/ib_stdio.h" #include #include "../jrd/common.h" @@ -743,7 +744,7 @@ static bool add_file(thread_db* tdbb, SSHORT phase, Deferred_work* work, USHORT section, shadow_number; SLONG start, max; BLK handle, handle2; - TEXT temp[MAXPATHLEN]; + Firebird::PathName temp; SET_TDBB(tdbb); Database* dbb = tdbb->tdbb_database; @@ -792,9 +793,9 @@ static bool add_file(thread_db* tdbb, SSHORT phase, Deferred_work* work, ** for shadows in add_shadow ()) */ if (work->dfw_type != dfw_add_shadow) { - ISC_expand_filename(X.RDB$FILE_NAME, 0, temp); + ISC_expand_filename(X.RDB$FILE_NAME, temp); MODIFY X USING - strcpy(X.RDB$FILE_NAME, temp); + strcpy(X.RDB$FILE_NAME, temp.c_str()); END_MODIFY; } @@ -879,7 +880,7 @@ static bool add_shadow( thread_db* tdbb, SSHORT phase, Deferred_work* work, USHORT sequence, add_sequence; bool finished; ULONG min_page; - TEXT expanded_fname[1024]; + Firebird::PathName expanded_fname; SET_TDBB(tdbb); Database* dbb = tdbb->tdbb_database; @@ -910,9 +911,9 @@ static bool add_shadow( thread_db* tdbb, SSHORT phase, Deferred_work* work, FOR(REQUEST_HANDLE handle) F IN RDB$FILES WITH F.RDB$FILE_NAME EQ work->dfw_name - ISC_expand_filename(F.RDB$FILE_NAME, 0, expanded_fname); + ISC_expand_filename(F.RDB$FILE_NAME, expanded_fname); MODIFY F USING - strcpy(F.RDB$FILE_NAME, expanded_fname); + strcpy(F.RDB$FILE_NAME, expanded_fname.c_str()); END_MODIFY; for (shadow = dbb->dbb_shadow; shadow; shadow = shadow->sdw_next) @@ -982,7 +983,7 @@ static bool add_shadow( thread_db* tdbb, SSHORT phase, Deferred_work* work, X IN RDB$FILES CROSS Y IN RDB$FILES OVER RDB$SHADOW_NUMBER - WITH X.RDB$FILE_NAME EQ expanded_fname + WITH X.RDB$FILE_NAME EQ expanded_fname.c_str() SORTED BY Y.RDB$FILE_START /* for the first file, create a brand new shadow; for secondary files that have a starting page specified, add a file */ @@ -1592,7 +1593,7 @@ static bool create_index( thread_db* tdbb, } if (IDX.RDB$INDEX_ID && IDX.RDB$STATISTICS < 0.0) { - SelectivityList selectivity(tdbb->tdbb_default); + SelectivityList selectivity(*tdbb->tdbb_default); const USHORT id = IDX.RDB$INDEX_ID - 1; IDX_statistics(tdbb, relation, id, selectivity); DFW_update_index(work->dfw_name, id, selectivity); @@ -1776,7 +1777,7 @@ static bool create_index( thread_db* tdbb, } fb_assert(work->dfw_id == dbb->dbb_max_idx); - SelectivityList selectivity(tdbb->tdbb_default); + SelectivityList selectivity(*tdbb->tdbb_default); IDX_create_index(tdbb, relation, &idx, work->dfw_name, &work->dfw_id, transaction, selectivity); fb_assert(work->dfw_id == idx.idx_id); diff --git a/src/jrd/dls.cpp b/src/jrd/dls.cpp index fd782fa0cd..2963bb1e55 100644 --- a/src/jrd/dls.cpp +++ b/src/jrd/dls.cpp @@ -215,10 +215,9 @@ MDLS* DLS_get_access(void) static bool is_initialized = false; if (!is_initialized) { is_initialized = true; - TempDirectoryList dir_list; + Firebird::TempDirectoryList dir_list; for (size_t i = 0; i < dir_list.Count(); i++) { - TempDirectoryList::Item item = dir_list[i]; - DLS_add_dir(item.size, item.dir.c_str()); + DLS_add_dir(dir_list[i].second, dir_list[i].first.c_str()); } } diff --git a/src/jrd/dyn_def.epp b/src/jrd/dyn_def.epp index 745c1edcc6..9f66951dc1 100644 --- a/src/jrd/dyn_def.epp +++ b/src/jrd/dyn_def.epp @@ -38,6 +38,7 @@ */ #include "firebird.h" +#include "fb_string.h" #include #include #include @@ -797,7 +798,6 @@ void DYN_define_file(GBL gbl, BLK request; SLONG temp; USHORT man_auto; - TEXT temp_f1[MAXPATHLEN], temp_f[MAXPATHLEN]; SSHORT id; thread_db* tdbb = GET_THREAD_DATA; @@ -811,14 +811,16 @@ void DYN_define_file(GBL gbl, request = CMP_find_request(tdbb, id = drq_l_files, DYN_REQUESTS); + TEXT temp_f1[MAXPATHLEN]; GET_STRING(ptr, temp_f1); - ISC_expand_filename(temp_f1, 0, temp_f); - if (!strcmp((char*)dbb->dbb_filename->str_data, temp_f)) { + Firebird::PathName temp_f; + ISC_expand_filename(temp_f1, temp_f); + if (dbb->dbb_filename == temp_f) { DYN_error_punt(false, 166, NULL, NULL, NULL, NULL, NULL); } FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) - FIRST 1 X IN RDB$FILES WITH X.RDB$FILE_NAME EQ temp_f + FIRST 1 X IN RDB$FILES WITH X.RDB$FILE_NAME EQ temp_f.c_str() DYN_error_punt(false, 166, NULL, NULL, NULL, NULL, NULL); END_FOR; @@ -826,7 +828,7 @@ void DYN_define_file(GBL gbl, STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$FILES - strcpy(X.RDB$FILE_NAME, temp_f); + strcpy(X.RDB$FILE_NAME, temp_f.c_str()); X.RDB$SHADOW_NUMBER = (SSHORT)shadow_number; X.RDB$FILE_FLAGS = 0; X.RDB$FILE_FLAGS.NULL = FALSE; @@ -2515,7 +2517,6 @@ void DYN_define_log_file( UCHAR verb; BLK request; SSHORT id; - STR db_filename; thread_db* tdbb = GET_THREAD_DATA; Database* dbb = tdbb->tdbb_database; @@ -2553,12 +2554,11 @@ void DYN_define_log_file( X.RDB$FILE_P_OFFSET.NULL = TRUE; if (default_log) { - db_filename = dbb->dbb_filename; - if (db_filename->str_length >= sizeof(X.RDB$FILE_NAME)) + if (dbb->dbb_filename.length() >= sizeof(X.RDB$FILE_NAME)) DYN_error_punt(false, 159, NULL, NULL, NULL, NULL, NULL); - memcpy(X.RDB$FILE_NAME, db_filename->str_data, - (int) db_filename->str_length); - X.RDB$FILE_NAME[db_filename->str_length] = '\0'; + memcpy(X.RDB$FILE_NAME, dbb->dbb_filename.c_str(), + dbb->dbb_filename.length()); + X.RDB$FILE_NAME[dbb->dbb_filename.length()] = '\0'; X.RDB$FILE_FLAGS.NULL = FALSE; X.RDB$FILE_FLAGS = LOG_default | LOG_serial; } diff --git a/src/jrd/err.cpp b/src/jrd/err.cpp index 91e8cf8aa0..0f374a0829 100644 --- a/src/jrd/err.cpp +++ b/src/jrd/err.cpp @@ -281,15 +281,8 @@ void ERR_log(int facility, int number, const TEXT* message) sprintf(errmsg + strlen(errmsg), " (%d)", number); - const UCHAR* dbname = 0; - if (tdbb && tdbb->tdbb_attachment) - { - dbname = ((tdbb->tdbb_attachment->att_filename) ? - tdbb->tdbb_attachment->att_filename->str_data : NULL); - } - - gds__log("Database: %s\n\t%s", - (dbname) ? reinterpret_cast(dbname) : "", + gds__log("Database: %s\n\t%s", (tdbb && tdbb->tdbb_attachment) ? + tdbb->tdbb_attachment->att_filename.c_str() : "", errmsg, 0); } #endif @@ -496,9 +489,8 @@ void ERR_punt(void) if (dbb && (dbb->dbb_flags & DBB_bugcheck)) { - const UCHAR* dbname = ((tdbb->tdbb_attachment->att_filename) ? - tdbb->tdbb_attachment->att_filename->str_data : NULL); - gds__log_status(reinterpret_cast(dbname), + gds__log_status(tdbb->tdbb_attachment->att_filename ? + tdbb->tdbb_attachment->att_filename.c_str() : NULL, tdbb->tdbb_status_vector); } diff --git a/src/jrd/evl_string.h b/src/jrd/evl_string.h index 01cf0c3dd2..74bb1b7664 100644 --- a/src/jrd/evl_string.h +++ b/src/jrd/evl_string.h @@ -32,7 +32,7 @@ * Contributor(s): * * - * $Id: evl_string.h,v 1.7 2004-02-20 06:42:59 robocop Exp $ + * $Id: evl_string.h,v 1.8 2004-03-14 13:39:45 alexpeshkoff Exp $ * */ @@ -112,11 +112,11 @@ static void preKmp(const CharType *x, int m, SSHORT kmpNext[]) { class StaticAllocator { public: - StaticAllocator(MemoryPool* _pool) : chunksToFree(_pool), pool(_pool), allocated(0) {}; + StaticAllocator(MemoryPool& _pool) : chunksToFree(_pool), pool(_pool), allocated(0) {}; ~StaticAllocator() { for (int i=0; i < chunksToFree.getCount(); i++) - pool->deallocate(chunksToFree[i]); + pool.deallocate(chunksToFree[i]); } void* alloc(SSHORT count) { @@ -127,14 +127,14 @@ public: return result; } else { - result = pool->allocate(count); + result = pool.allocate(count); chunksToFree.add(result); return result; } } private: Array chunksToFree; - MemoryPool* pool; + MemoryPool& pool; char allocBuffer[STATIC_PATTERN_BUFFER]; int allocated; }; @@ -142,7 +142,7 @@ private: template class ContainsEvaluator : private StaticAllocator { public: - ContainsEvaluator(MemoryPool* _pool, const CharType* _pattern_str, SSHORT _pattern_len) : + ContainsEvaluator(MemoryPool& _pool, const CharType* _pattern_str, SSHORT _pattern_len) : StaticAllocator(_pool), pattern_len(_pattern_len) { CharType* temp = reinterpret_cast(alloc(_pattern_len*sizeof(CharType))); @@ -207,7 +207,7 @@ enum MatchType { template class LikeEvaluator : private StaticAllocator { public: - LikeEvaluator(MemoryPool* _pool, const CharType* _pattern_str, + LikeEvaluator(MemoryPool& _pool, const CharType* _pattern_str, SSHORT pattern_len, CharType escape_char, CharType sql_match_any, CharType sql_match_one); @@ -258,7 +258,7 @@ private: template LikeEvaluator::LikeEvaluator( - MemoryPool* _pool, const CharType* _pattern_str, SSHORT pattern_len, + MemoryPool& _pool, const CharType* _pattern_str, SSHORT pattern_len, CharType escape_char, CharType sql_match_any, CharType sql_match_one) : StaticAllocator(_pool), patternItems(_pool), branches(_pool), match_type(MATCH_NONE) { diff --git a/src/jrd/exe.cpp b/src/jrd/exe.cpp index aa2701e889..658bd8b513 100644 --- a/src/jrd/exe.cpp +++ b/src/jrd/exe.cpp @@ -1074,7 +1074,7 @@ inline void PreModifyEraseTriggers(thread_db* tdbb, if (! tdbb->tdbb_transaction->tra_rpblist) { tdbb->tdbb_transaction->tra_rpblist = FB_NEW(*tdbb->tdbb_transaction->tra_pool) - traRpbList(tdbb->tdbb_transaction->tra_pool); + traRpbList(*tdbb->tdbb_transaction->tra_pool); } const int rpblevel = tdbb->tdbb_transaction-> tra_rpblist->PushRpb(rpb); diff --git a/src/jrd/exe.h b/src/jrd/exe.h index c03bdd51ce..be6450ffd8 100644 --- a/src/jrd/exe.h +++ b/src/jrd/exe.h @@ -585,10 +585,10 @@ public: csb_msg_number(0), csb_impure(0), csb_g_flags(0),*/ - csb_fors(&p), - csb_invariants(&p), - csb_current_nodes(&p), - csb_rpt(&p, len) + csb_fors(p), + csb_invariants(p), + csb_current_nodes(p), + csb_rpt(p, len) {} static Csb* newCsb(MemoryPool& p, size_t len) diff --git a/src/jrd/execute_statement.cpp b/src/jrd/execute_statement.cpp index 9abd273450..725f4ef402 100644 --- a/src/jrd/execute_statement.cpp +++ b/src/jrd/execute_statement.cpp @@ -43,6 +43,7 @@ #define WHY_NO_API #include "../jrd/why_proto.h" +#include "../common/classes/auto.h" #include "../jrd/execute_statement.h" WHY_DBB GetWhyAttachment(ISC_STATUS* status, @@ -91,7 +92,7 @@ void ExecuteStatement::Open(thread_db* tdbb, jrd_nod* sql, SSHORT nVars, bool Si fb_assert(tdbb->tdbb_transaction->tra_pool); // We allocated char[N]; therefore, make sure we deallocate char's and with delete[] - AutoPtrFromString v = reinterpret_cast ( + Firebird::AutoPtrFromString v = reinterpret_cast ( FB_NEW(*tdbb->tdbb_transaction->tra_pool) char[BUFFER_LARGE + sizeof(vary)]); v->vary_length = BUFFER_LARGE; UCHAR* p = 0; diff --git a/src/jrd/execute_statement.h b/src/jrd/execute_statement.h index f33d882cd5..957748b237 100644 --- a/src/jrd/execute_statement.h +++ b/src/jrd/execute_statement.h @@ -33,7 +33,6 @@ #include "../jrd/exe.h" #include "../jrd/y_ref.h" #include "../jrd/ibase.h" -#include "../common/classes/auto.h" #define MAX_CALLBACKS 50 diff --git a/src/jrd/ext.cpp b/src/jrd/ext.cpp index 118ce49268..3cdbe45e43 100644 --- a/src/jrd/ext.cpp +++ b/src/jrd/ext.cpp @@ -57,26 +57,35 @@ #include "../common/config/config.h" #include "../common/config/dir_list.h" #include "../jrd/os/path_utils.h" +#include "../common/classes/init.h" namespace { -IB_FILE *ext_fopen(const char *filename, const char *mode); + IB_FILE *ext_fopen(const char *filename, const char *mode); -class ExternalFileDirectoryList : public DirectoryList { - const Firebird::PathName GetConfigString(void) const { - return Firebird::PathName(Config::getExternalFileAccess()); + class ExternalFileDirectoryList : public Firebird::DirectoryList + { + private: + const Firebird::PathName getConfigString(void) const { + return Firebird::PathName(Config::getExternalFileAccess()); + } + public: + ExternalFileDirectoryList(MemoryPool& p) : DirectoryList(p) + { + initialize(); + } + }; + Firebird::InitInstance iExternalFileDirectoryList; + + IB_FILE *ext_fopen(const char *filename, const char *mode) { + if (!iExternalFileDirectoryList().isPathInList(filename)) + ERR_post(isc_conf_access_denied, + isc_arg_string, "external file", + isc_arg_string, ERR_cstring(filename), + isc_arg_end); + + return ib_fopen(filename, mode); } -} iExternalFileDirectoryList; - -IB_FILE *ext_fopen(const char *filename, const char *mode) { - if (!iExternalFileDirectoryList.IsPathInList(filename)) - ERR_post(isc_conf_access_denied, - isc_arg_string, "external file", - isc_arg_string, ERR_cstring(filename), - isc_arg_end); - - return ib_fopen(filename, mode); } -}; #ifdef WIN_NT #define FOPEN_TYPE "a+b" @@ -160,7 +169,7 @@ EXT EXT_file(jrd_rel* relation, const TEXT* file_name, bid* description) Firebird::PathName Path, Name; PathUtils::splitLastComponent(Path, Name, file_name); if (Path.length() == 0) { // path component not present in file_name - iExternalFileDirectoryList.ExpandFileName(Path, Name, 4); + iExternalFileDirectoryList().expandFileName(Path, Name, 4); file_name = Path.c_str(); } diff --git a/src/jrd/flu.cpp b/src/jrd/flu.cpp index 1f45a7be80..26f91534ad 100644 --- a/src/jrd/flu.cpp +++ b/src/jrd/flu.cpp @@ -43,13 +43,14 @@ * */ /* -$Id: flu.cpp,v 1.45 2004-02-20 06:43:00 robocop Exp $ +$Id: flu.cpp,v 1.46 2004-03-14 13:39:45 alexpeshkoff Exp $ */ #include "firebird.h" #include "../common/config/config.h" #include "../common/config/dir_list.h" #include "../jrd/os/path_utils.h" +#include "../common/classes/init.h" #include "../jrd/common.h" #include "../jrd/flu.h" @@ -831,6 +832,22 @@ static int condition_handler(int *sig, int *mech, int *enbl) } #endif +namespace { + class UdfDirectoryList : public Firebird::DirectoryList + { + private: + const Firebird::PathName getConfigString(void) const { + return Firebird::PathName(Config::getUdfAccess()); + } + public: + UdfDirectoryList(MemoryPool& p) : DirectoryList(p) + { + initialize(); + } + }; + Firebird::InitInstance iUdfDirectoryList; +} + static MOD search_for_module(TEXT* module_name, TEXT* name, bool ShowAccessError) { /************************************** @@ -847,12 +864,7 @@ static MOD search_for_module(TEXT* module_name, TEXT* name, bool ShowAccessError #ifndef REQUIRED_MODULE_ACCESS return NULL; #else - static class UdfDirectoryList : public DirectoryList { - const Firebird::PathName GetConfigString(void) const { - return Firebird::PathName(Config::getUdfAccess()); - } - } iUdfDirectoryList; - + Firebird::PathName path, relative; Firebird::PathName absolute_module = module_name; @@ -860,12 +872,12 @@ static MOD search_for_module(TEXT* module_name, TEXT* name, bool ShowAccessError PathUtils::splitLastComponent(path, relative, absolute_module); if (path.length() == 0 && PathUtils::isRelative(absolute_module)) { relative = absolute_module; - iUdfDirectoryList.ExpandFileName(absolute_module, relative, REQUIRED_MODULE_ACCESS); + iUdfDirectoryList().expandFileName(absolute_module, relative, REQUIRED_MODULE_ACCESS); } // The module name, including directory path, // must satisfy UdfAccess entry in config file. - if (!iUdfDirectoryList.IsPathInList(absolute_module)) { + if (!iUdfDirectoryList().isPathInList(absolute_module)) { if (ShowAccessError) { ERR_post(isc_conf_access_denied, isc_arg_string, "UDF library", diff --git a/src/jrd/gds.cpp b/src/jrd/gds.cpp index 96bf675208..127c6a93f0 100644 --- a/src/jrd/gds.cpp +++ b/src/jrd/gds.cpp @@ -1615,8 +1615,6 @@ void API_ROUTINE gds__prefix(TEXT* resultString, const TEXT* file) * * Functional description * Find appropriate file prefix. - * Override conditional defines with - * the enviroment variable FIREBIRD if it is set. * **************************************/ resultString[0] = 0; diff --git a/src/jrd/inf.cpp b/src/jrd/inf.cpp index 5737824176..63614d4d6a 100644 --- a/src/jrd/inf.cpp +++ b/src/jrd/inf.cpp @@ -458,10 +458,10 @@ int INF_database_info(const SCHAR* items, case isc_info_db_id: { - const str* str_fn = tdbb->tdbb_attachment->att_filename; + const Firebird::PathName& str_fn = tdbb->tdbb_attachment->att_filename; STUFF(p, 2); - *p++ = l = str_fn->str_length; - for (q = reinterpret_cast(str_fn->str_data); *q;) + *p++ = l = str_fn.length(); + for (q = str_fn.c_str(); *q;) *p++ = *q++; ISC_get_host(site, sizeof(site)); *p++ = l = strlen(site); diff --git a/src/jrd/ini.epp b/src/jrd/ini.epp index 63500929fd..61685dde46 100644 --- a/src/jrd/ini.epp +++ b/src/jrd/ini.epp @@ -959,7 +959,7 @@ static void add_index_set(Database* dbb, } idx.idx_count = index->ini_idx_segment_count; idx.idx_flags = index->ini_idx_flags; - SelectivityList selectivity(tdbb->tdbb_default); + SelectivityList selectivity(*tdbb->tdbb_default); IDX_create_index(tdbb, relation, &idx, string, NULL, NULL, selectivity); X.RDB$INDEX_ID = idx.idx_id + 1; diff --git a/src/jrd/jrd_proto.h b/src/jrd/jrd_proto.h index 0e4140f3dd..741b64dbe9 100644 --- a/src/jrd/jrd_proto.h +++ b/src/jrd/jrd_proto.h @@ -40,6 +40,9 @@ #endif /* __cplusplus */ #ifdef __cplusplus + +#include "fb_string.h" + extern "C" { #endif @@ -168,7 +171,7 @@ void JRD_wlck_unlock(struct mutx_t *); #ifdef SUPERSERVER void JRD_print_all_counters(const TEXT*); -USHORT JRD_getdir(TEXT*, USHORT); +bool JRD_getdir(Firebird::PathName&); #endif #ifdef DEBUG_PROCS @@ -179,5 +182,19 @@ void JRD_print_procedure_info(thread_db*, const char*); } /* extern "C" */ #endif +inline bool fb_getcwd(Firebird::PathName& pn) +{ + char buffer[MAXPATHLEN]; +#if defined(WIN_NT) + _getcwd(buffer, MAXPATHLEN); +#elif defined(HAVE_GETCWD) + getcwd(buffer, MAXPATHLEN); +#else + getwd(buffer); +#endif + pn = buffer; + return bool(buffer); +} + #endif /* JRD_JRD_PROTO_H */ diff --git a/src/jrd/nbak.cpp b/src/jrd/nbak.cpp index 099f32803a..c6ee1be46d 100644 --- a/src/jrd/nbak.cpp +++ b/src/jrd/nbak.cpp @@ -32,7 +32,7 @@ * Contributor(s): * * - * $Id: nbak.cpp,v 1.25 2004-03-13 01:57:52 skidder Exp $ + * $Id: nbak.cpp,v 1.26 2004-03-14 13:39:46 alexpeshkoff Exp $ * */ @@ -504,7 +504,7 @@ int BackupManager::backup_database_ast(void *ast_object) throw() /********************************** CORE LOGIC ********************************/ void BackupManager::generate_filename() throw() { - strncpy(diff_name, (char*)database->dbb_filename->str_data, sizeof(diff_name)); + strncpy(diff_name, (char*)database->dbb_filename.c_str(), sizeof(diff_name)); strncat(diff_name, ".delta", sizeof(diff_name)-strlen(diff_name)-1); } diff --git a/src/jrd/opt.cpp b/src/jrd/opt.cpp index f27cc69914..43e978295d 100644 --- a/src/jrd/opt.cpp +++ b/src/jrd/opt.cpp @@ -2024,7 +2024,7 @@ static USHORT distribute_equalities(LLS * org_stack, Csb* csb, USHORT base_count * operation '$'. * **************************************/ - Firebird::HalfStaticArray classes(GET_THREAD_DATA->tdbb_default); + Firebird::HalfStaticArray classes(*GET_THREAD_DATA->tdbb_default); LLS *eq_class, stack; DEV_BLKCHK(*org_stack, type_lls); @@ -2901,7 +2901,7 @@ static void find_best(thread_db* tdbb, // Save the various flag bits from the optimizer block to reset its // state after each test. Firebird::HalfStaticArray - stream_flags(tdbb->tdbb_default), conjunct_flags(tdbb->tdbb_default); + stream_flags(*tdbb->tdbb_default), conjunct_flags(*tdbb->tdbb_default); stream_flags.grow(csb->csb_n_stream); conjunct_flags.grow(opt->opt_base_conjuncts); int i; @@ -4287,10 +4287,10 @@ static Rsb* gen_retrieval(thread_db* tdbb, could be calculated via the index; currently we won't detect that case */ - Firebird::HalfStaticArray idx_walk_vector(tdbb->tdbb_default); + Firebird::HalfStaticArray idx_walk_vector(*tdbb->tdbb_default); idx_walk_vector.grow(csb_tail->csb_indices); IDX** idx_walk = idx_walk_vector.begin(); - Firebird::HalfStaticArray idx_priority_level_vector(tdbb->tdbb_default); + Firebird::HalfStaticArray idx_priority_level_vector(*tdbb->tdbb_default); idx_priority_level_vector.grow(csb_tail->csb_indices); UINT64* idx_priority_level = idx_priority_level_vector.begin(); @@ -4382,10 +4382,10 @@ static Rsb* gen_retrieval(thread_db* tdbb, // when necessary build the index Firebird::HalfStaticArray - conjunct_position_vector(tdbb->tdbb_default); + conjunct_position_vector(*tdbb->tdbb_default); Firebird::HalfStaticArray - matching_nodes_vector(tdbb->tdbb_default); + matching_nodes_vector(*tdbb->tdbb_default); for (i = 0; i < idx_walk_count; i++) { @@ -4983,7 +4983,7 @@ static bool gen_sort_merge(thread_db* tdbb, OPT opt, LLS * org_rivers) river1->riv_number = cnt++; } - Firebird::HalfStaticArray scratch(tdbb->tdbb_default); + Firebird::HalfStaticArray scratch(*tdbb->tdbb_default); scratch.grow(opt->opt_base_conjuncts * cnt); jrd_nod** classes = scratch.begin(); @@ -5042,7 +5042,7 @@ static bool gen_sort_merge(thread_db* tdbb, OPT opt, LLS * org_rivers) to indicate that nothing could be done. */ USHORT river_cnt = 0, stream_cnt = 0; - Firebird::HalfStaticArray selected_classes(tdbb->tdbb_default, cnt); + Firebird::HalfStaticArray selected_classes(*tdbb->tdbb_default, cnt); for (eq_class = classes; eq_class < last_class; eq_class += cnt) { i = river_count(cnt, eq_class); if (i > river_cnt) { @@ -5611,11 +5611,11 @@ static jrd_nod* make_inversion(thread_db* tdbb, OPT opt, jrd_nod* boolean, USHOR // TMN: Shouldn't this be allocated from the tdbb->tdbb_default pool? Firebird::HalfStaticArray - idx_walk_vector(tdbb->tdbb_default); + idx_walk_vector(*tdbb->tdbb_default); idx_walk_vector.grow(csb_tail->csb_indices); IDX** idx_walk = idx_walk_vector.begin(); Firebird::HalfStaticArray - idx_priority_level_vector(tdbb->tdbb_default); + idx_priority_level_vector(*tdbb->tdbb_default); idx_priority_level_vector.grow(csb_tail->csb_indices); UINT64* idx_priority_level = idx_priority_level_vector.begin(); @@ -6738,7 +6738,7 @@ static void sort_indices_by_selectivity(csb_repeat* csb_tail) IDX* selected_idx = NULL; USHORT i, j; - Firebird::Array idx_sort(GET_THREAD_DATA->tdbb_default, csb_tail->csb_indices); + Firebird::Array idx_sort(*GET_THREAD_DATA->tdbb_default, csb_tail->csb_indices); float selectivity; bool same_selectivity = false; @@ -6808,7 +6808,7 @@ static SSHORT sort_indices_by_priority(csb_repeat * csb_tail, * Sort indices based on the priority level. * ***************************************************/ - Firebird::HalfStaticArray idx_csb(GET_THREAD_DATA->tdbb_default); + Firebird::HalfStaticArray idx_csb(*GET_THREAD_DATA->tdbb_default); idx_csb.grow(csb_tail->csb_indices); memcpy(idx_csb.begin(), idx_walk, csb_tail->csb_indices * sizeof(IDX*)); diff --git a/src/jrd/os/win32/winnt.cpp b/src/jrd/os/win32/winnt.cpp index 8dc012eaa5..5b3791e697 100644 --- a/src/jrd/os/win32/winnt.cpp +++ b/src/jrd/os/win32/winnt.cpp @@ -395,7 +395,7 @@ void PIO_header(Database* dbb, SCHAR * address, int length) nt_error("ReadFile", file, isc_io_read_err, 0); } - (*dbb->dbb_decrypt) (reinterpret_cast(dbb->dbb_encrypt_key->str_data), + (*dbb->dbb_decrypt) (dbb->dbb_encrypt_key.c_str(), spare_buffer, length, address); } else @@ -608,7 +608,7 @@ bool PIO_read(jrd_file* file, Buffer_desc* bdb, PAG page, ISC_STATUS* status_vec return nt_error("ReadFile", file, isc_io_read_err, status_vector); } - (*dbb->dbb_decrypt) (reinterpret_cast(dbb->dbb_encrypt_key->str_data), + (*dbb->dbb_decrypt) (dbb->dbb_encrypt_key.c_str(), spare_buffer, size, page); } else @@ -821,7 +821,7 @@ bool PIO_write(jrd_file* file, Buffer_desc* bdb, PAG page, ISC_STATUS* status_ve if (dbb->dbb_encrypt_key) { SLONG spare_buffer[MAX_PAGE_SIZE / sizeof(SLONG)]; - (*dbb->dbb_encrypt) (reinterpret_cast(dbb->dbb_encrypt_key->str_data), + (*dbb->dbb_encrypt) (dbb->dbb_encrypt_key.c_str(), page, size, spare_buffer); if (!WriteFile(desc, spare_buffer, size, &actual_length, overlapped_ptr) diff --git a/src/jrd/req.h b/src/jrd/req.h index 9c6dc5c875..e55ece671d 100644 --- a/src/jrd/req.h +++ b/src/jrd/req.h @@ -135,7 +135,7 @@ typedef srpb *SRPB; class jrd_req : public pool_alloc_rpt { public: - jrd_req(JrdMemoryPool* pool) : req_fors(pool), req_invariants(pool) { }; + jrd_req(JrdMemoryPool* pool) : req_fors(*pool), req_invariants(*pool) { }; ATT req_attachment; // database attachment USHORT req_count; // number of streams USHORT req_incarnation; // incarnation number diff --git a/src/jrd/rse.cpp b/src/jrd/rse.cpp index e01cdfd7f6..57e7a692be 100644 --- a/src/jrd/rse.cpp +++ b/src/jrd/rse.cpp @@ -20,7 +20,7 @@ * All Rights Reserved. * Contributor(s): ______________________________________. * - * $Id: rse.cpp,v 1.59 2004-03-11 05:03:58 robocop Exp $ + * $Id: rse.cpp,v 1.60 2004-03-14 13:39:46 alexpeshkoff Exp $ * * 2001.07.28: John Bellardo: Implemented rse_skip and made rse_first work with * seekable streams. @@ -3311,7 +3311,7 @@ static void pop_rpbs(jrd_req* request, Rsb* rsb) * **************************************/ // temporary sparse bitmap of the used streams - Firebird::HalfStaticArray streams(request->req_pool); + Firebird::HalfStaticArray streams(*request->req_pool); switch (rsb->rsb_type) { case rsb_indexed: @@ -3424,7 +3424,7 @@ static void push_rpbs(thread_db* tdbb, jrd_req* request, Rsb* rsb) SET_TDBB(tdbb); // temporary sparse bitmap of the used streams - Firebird::HalfStaticArray streams(request->req_pool); + Firebird::HalfStaticArray streams(*request->req_pool); switch (rsb->rsb_type) { case rsb_indexed: diff --git a/src/jrd/rse.h b/src/jrd/rse.h index 45105f2a61..13b1fdefe1 100644 --- a/src/jrd/rse.h +++ b/src/jrd/rse.h @@ -339,7 +339,7 @@ public: }; Firebird::HalfStaticArray opt_conjuncts; Firebird::HalfStaticArray opt_streams; - Opt(JrdMemoryPool* pool) : opt_conjuncts(pool), opt_streams(pool) {} + Opt(JrdMemoryPool* pool) : opt_conjuncts(*pool), opt_streams(*pool) {} }; typedef Opt* OPT; diff --git a/src/jrd/shut.cpp b/src/jrd/shut.cpp index 22249c3963..001d1429e1 100644 --- a/src/jrd/shut.cpp +++ b/src/jrd/shut.cpp @@ -390,7 +390,7 @@ static bool bad_mode(bool ignore) { *status++ = isc_bad_shutdown_mode; *status++ = isc_arg_string; *status++ = (ISC_STATUS) (IPTR) - ERR_cstring(reinterpret_cast(tdbb->tdbb_database->dbb_filename->str_data)); + ERR_cstring(reinterpret_cast(tdbb->tdbb_database->dbb_filename.c_str())); *status++ = isc_arg_end; } return ignore; diff --git a/src/jrd/tra.cpp b/src/jrd/tra.cpp index 31092469ea..ae76f9f282 100644 --- a/src/jrd/tra.cpp +++ b/src/jrd/tra.cpp @@ -1397,8 +1397,8 @@ jrd_tra* TRA_start(thread_db* tdbb, int tpb_length, const SCHAR* tpb) if (dbb->dbb_ast_flags & DBB_shut_tran) { ERR_post(isc_shutinprog, isc_arg_cstring, - tdbb->tdbb_attachment->att_filename->str_length, - tdbb->tdbb_attachment->att_filename->str_data, + tdbb->tdbb_attachment->att_filename.length(), + tdbb->tdbb_attachment->att_filename.c_str(), 0); } @@ -2643,8 +2643,7 @@ static BOOLEAN start_sweeper(thread_db* tdbb, Database* dbb) LCK_release(tdbb, &temp_lock); /* allocate space for the string and a null at the end */ - const char* pszFilename = - reinterpret_cast(tdbb->tdbb_attachment->att_filename->str_data); + const char* pszFilename = tdbb->tdbb_attachment->att_filename.c_str(); char* database = (char*)gds__alloc(strlen(pszFilename) + 1); diff --git a/src/jrd/val.cpp b/src/jrd/val.cpp index 09fc038bcf..1288ae9271 100644 --- a/src/jrd/val.cpp +++ b/src/jrd/val.cpp @@ -769,7 +769,7 @@ static RTN corrupt(thread_db* tdbb, VDR control, USHORT err_code, jrd_rel* relat const TEXT* string = msg_table[err_code]; sprintf(s, "Database: %s\n\t", - tdbb->tdbb_attachment->att_filename->str_data); + tdbb->tdbb_attachment->att_filename.c_str()); TEXT* p; for (p = s; *p; p++) diff --git a/src/jrd/vio.cpp b/src/jrd/vio.cpp index c2337a92d1..79fcb38830 100644 --- a/src/jrd/vio.cpp +++ b/src/jrd/vio.cpp @@ -3574,8 +3574,7 @@ static void THREAD_ROUTINE garbage_collector(Database* dbb) /* Pseudo attachment needed for lock owner identification. */ - tdbb->tdbb_attachment = FB_NEW(*dbb->dbb_permanent) att(); - tdbb->tdbb_attachment->att_database = dbb; + tdbb->tdbb_attachment = FB_NEW(*dbb->dbb_permanent) att(dbb); tdbb->tdbb_attachment->att_filename = dbb->dbb_filename; tdbb->tdbb_attachment->att_flags = ATT_garbage_collector; diff --git a/src/remote/interface.cpp b/src/remote/interface.cpp index 9e7edfa108..2f65279fdf 100644 --- a/src/remote/interface.cpp +++ b/src/remote/interface.cpp @@ -36,6 +36,7 @@ #include #include "../remote/remote.h" #include "../jrd/gdsassert.h" +#include "../jrd/jrd_proto.h" #include #ifndef NO_NFS @@ -4617,25 +4618,19 @@ static void add_working_directory(UCHAR* dpb_or_spb, * settings that the server should know about. * ************************************************/ - char cwd[MAXPATHLEN]; + Firebird::PathName cwd; if (node_name && !strcmp(node_name, "localhost")) { - fb_getcwd(cwd, sizeof(cwd)); + fb_getcwd(cwd); } - else - { - /** Remote database. Pass Null **/ - cwd[0] = 0; - } - const USHORT len = strlen(cwd); if (*length == 0) { dpb_or_spb[(*length)++] = isc_dpb_version1; } dpb_or_spb[(*length)++] = isc_dpb_working_directory; - dpb_or_spb[(*length)++] = len; - memcpy(&(dpb_or_spb[(*length)]), cwd, len); - *length += len; + dpb_or_spb[(*length)++] = cwd.length(); + memcpy(&(dpb_or_spb[(*length)]), cwd.c_str(), cwd.length()); + *length += cwd.length(); } diff --git a/src/utilities/gstat/dba.epp b/src/utilities/gstat/dba.epp index 5c798cd61d..bd0bea41db 100644 --- a/src/utilities/gstat/dba.epp +++ b/src/utilities/gstat/dba.epp @@ -30,6 +30,7 @@ #include "firebird.h" +#include "fb_string.h" #include "../jrd/common.h" #include "../jrd/ib_stdio.h" #include "../common/classes/alloc.h" @@ -496,9 +497,9 @@ int CLIB_ROUTINE main(int argc, char** argv) /* Open database and go to work */ - TEXT temp_buf[MAXPATHLEN]; - if (ResolveDatabaseAlias(name, temp_buf)) { - name = temp_buf; + Firebird::PathName temp_buf = name; + if (ResolveDatabaseAlias(temp_buf, temp_buf)) { + name = temp_buf.c_str(); } dba_fil* current = db_open(name, strlen(name));