summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-02-01 10:01:52 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-02-01 10:01:52 +0000
commitfa588f6bab7b72f0d6d49d7f5e6eff46eb04ebbb (patch)
tree6a146bd561aec0da75a9630185619a99dbd4b065
parenteda7bc28bba8d4649e95d489e50832ba2cc1e723 (diff)
downloadATCD-fa588f6bab7b72f0d6d49d7f5e6eff46eb04ebbb.tar.gz
*** empty log message ***
-rw-r--r--ace/Hash_Map_Manager.cpp10
-rw-r--r--ace/Hash_Map_Manager.h3
-rw-r--r--ace/Local_Name_Space.cpp13
-rw-r--r--ace/Local_Name_Space.h7
-rw-r--r--ace/Local_Name_Space_T.h9
-rw-r--r--ace/Naming_Context.cpp6
-rw-r--r--ace/Registry.cpp2
-rw-r--r--ace/Registry.h2
-rw-r--r--ace/Registry_Name_Space.cpp24
-rw-r--r--ace/Registry_Name_Space.h3
-rw-r--r--ace/SString.cpp37
-rw-r--r--ace/SString.h10
12 files changed, 111 insertions, 15 deletions
diff --git a/ace/Hash_Map_Manager.cpp b/ace/Hash_Map_Manager.cpp
index 3d949926989..fcb691c5119 100644
--- a/ace/Hash_Map_Manager.cpp
+++ b/ace/Hash_Map_Manager.cpp
@@ -124,6 +124,16 @@ ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::ACE_Hash_Map_Manager (size_t size,
ACE_ERROR ((LM_ERROR, "ACE_Hash_Map_Manager\n"));
}
+template <class EXT_ID, class INT_ID, class LOCK>
+ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::ACE_Hash_Map_Manager (ACE_Allocator *allocator)
+ : total_size_ (0),
+ cur_size_ (0),
+ allocator_ (allocator)
+{
+ if (this->open (DEFAULT_SIZE, allocator) == -1)
+ ACE_ERROR ((LM_ERROR, "ACE_Hash_Map_Manager\n"));
+}
+
template <class EXT_ID, class INT_ID, class LOCK> int
ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::close_i (void)
{
diff --git a/ace/Hash_Map_Manager.h b/ace/Hash_Map_Manager.h
index a37051368d6..cedd589579f 100644
--- a/ace/Hash_Map_Manager.h
+++ b/ace/Hash_Map_Manager.h
@@ -82,6 +82,9 @@ public:
ACE_Allocator *allocator = 0);
// Initialize a <Hash_Map_Manager> with size <length>.
+ ACE_Hash_Map_Manager (ACE_Allocator *allocator = 0);
+ // Initialize a <Hash_Map_Manager> with default size.
+
int open (size_t length = DEFAULT_SIZE,
ACE_Allocator *allocator = 0);
// Initialize a <Hash_Map_Manager> with size <length>.
diff --git a/ace/Local_Name_Space.cpp b/ace/Local_Name_Space.cpp
index 2cf194b6f6c..f7edfbf11ec 100644
--- a/ace/Local_Name_Space.cpp
+++ b/ace/Local_Name_Space.cpp
@@ -93,6 +93,13 @@ ACE_NS_String::operator == (const ACE_NS_String &s) const
(void *) s.rep_, this->len_) == 0;
}
+int
+ACE_NS_String::operator != (const ACE_NS_String &s) const
+{
+ ACE_TRACE ("ACE_NS_String::operator !=");
+ return !this->operator == (s);
+}
+
ACE_NS_String::ACE_NS_String (ACE_USHORT16 *dst,
const ACE_USHORT16 *src,
size_t bytes)
@@ -103,6 +110,12 @@ ACE_NS_String::ACE_NS_String (ACE_USHORT16 *dst,
ACE_OS::memcpy (this->rep_, src, bytes);
}
+size_t
+ACE_NS_String::hash (void) const
+{
+ return ACE::hash_pjw (this->rep_);
+}
+
ACE_NS_Internal::ACE_NS_Internal (void)
{
}
diff --git a/ace/Local_Name_Space.h b/ace/Local_Name_Space.h
index e02d9c288b6..e1639c841d4 100644
--- a/ace/Local_Name_Space.h
+++ b/ace/Local_Name_Space.h
@@ -21,7 +21,6 @@
#if !defined (ACE_LOCAL_NAME_SPACE_H)
#define ACE_LOCAL_NAME_SPACE_H
-#include "ace/Map_Manager.h"
#include "ace/Service_Config.h"
#include "ace/SString.h"
#include "ace/Set.h"
@@ -64,12 +63,18 @@ public:
int operator == (const ACE_NS_String &) const;
// Compare an ACE_NS_String.
+ int operator != (const ACE_NS_String &) const;
+ // Compare an ACE_NS_String.
+
size_t len (void) const;
// Returns length of the string
ACE_USHORT16 *fast_rep (void) const;
// Returns the underlying representation.
+ size_t hash (void) const;
+ // Returns a hash value for this string.
+
private:
size_t len_;
// Length of the string.
diff --git a/ace/Local_Name_Space_T.h b/ace/Local_Name_Space_T.h
index 616019884a9..e223721be91 100644
--- a/ace/Local_Name_Space_T.h
+++ b/ace/Local_Name_Space_T.h
@@ -21,6 +21,7 @@
#if !defined (ACE_LOCAL_NAME_SPACE_T_H)
#define ACE_LOCAL_NAME_SPACE_T_H
+#include "ace/Hash_Map_Manager.h"
#include "ace/Name_Space.h"
#include "ace/Naming_Context.h"
#include "ace/SString.h"
@@ -31,9 +32,9 @@
typedef ACE_Unbounded_Set<ACE_WString> ACE_WSTRING_SET;
// Simplify later usage by defining typedefs.
-typedef ACE_Map_Manager<ACE_NS_String, ACE_NS_Internal, ACE_Null_Mutex> MAP_MANAGER;
-typedef ACE_Map_Iterator<ACE_NS_String, ACE_NS_Internal, ACE_Null_Mutex> MAP_ITERATOR;
-typedef ACE_Map_Entry <ACE_NS_String, ACE_NS_Internal> MAP_ENTRY;
+typedef ACE_Hash_Map_Manager<ACE_NS_String, ACE_NS_Internal, ACE_Null_Mutex> MAP_MANAGER;
+typedef ACE_Hash_Map_Iterator<ACE_NS_String, ACE_NS_Internal, ACE_Null_Mutex> MAP_ITERATOR;
+typedef ACE_Hash_Map_Entry <ACE_NS_String, ACE_NS_Internal> MAP_ENTRY;
template <class ALLOCATOR>
class ACE_Name_Space_Map : public MAP_MANAGER
@@ -55,7 +56,7 @@ public:
// Constructor.
// = The following methods are Proxies to the underlying methods
- // provided by <ACE_Map_Manager>. When they are called, they
+ // provided by <ACE_Hash_Map_Manager>. When they are called, they
// acquire the lock, set the allocator to the one specific to this
// process, and then call down to perform the intended operation.
int bind (const ACE_NS_String &,
diff --git a/ace/Naming_Context.cpp b/ace/Naming_Context.cpp
index ed3e8c5fde1..8402d181fd7 100644
--- a/ace/Naming_Context.cpp
+++ b/ace/Naming_Context.cpp
@@ -388,6 +388,7 @@ void
ACE_Name_Options::namespace_dir (LPCTSTR dir)
{
ACE_TRACE ("ACE_Name_Options::namespace_dir");
+ ACE_OS::free ((void *) this->namespace_dir_ );
this->namespace_dir_ = ACE_OS::strdup (dir);
}
@@ -396,6 +397,7 @@ ACE_Name_Options::process_name (LPCTSTR pname)
{
ACE_TRACE ("ACE_Name_Options::process_name");
LPCTSTR t = ACE::basename (pname, ACE_DIRECTORY_SEPARATOR_CHAR);
+ ACE_OS::free ((void *) this->process_name_ );
this->process_name_ = ACE_OS::strdup (t);
}
@@ -403,6 +405,7 @@ void
ACE_Name_Options::nameserver_host (const char *host)
{
ACE_TRACE ("ACE_Name_Options::nameserver_host");
+ ACE_OS::free ((void *) this->nameserver_host_);
this->nameserver_host_ = ACE_OS::strdup (host);
}
@@ -424,8 +427,7 @@ void
ACE_Name_Options::database (LPCTSTR db)
{
ACE_TRACE ("ACE_Name_Options::database");
- if (this->database_ != 0)
- ACE_OS::free ((void *) this->database_);
+ ACE_OS::free ((void *) this->database_);
this->database_ = ACE_OS::strdup (db);
}
diff --git a/ace/Registry.cpp b/ace/Registry.cpp
index 204e8e4e9f3..67e4e5800bc 100644
--- a/ace/Registry.cpp
+++ b/ace/Registry.cpp
@@ -906,7 +906,7 @@ ACE_Registry::Binding_Iterator::Object_Iteration::next_n (u_long how_many,
// While there are more entries to be added to the list
while (how_many > 0)
{
- TCHAR string [ACE_Registry::Naming_Context::MAX_CONTEXT_NAME_SIZE];
+ TCHAR string [ACE_Registry::Naming_Context::MAX_OBJECT_NAME_SIZE];
u_long size = sizeof string / sizeof (TCHAR);
long result = ::RegEnumValue (this->parent_->naming_context (). key(),
this->index_,
diff --git a/ace/Registry.h b/ace/Registry.h
index 061c5e16547..6c02f88a3cc 100644
--- a/ace/Registry.h
+++ b/ace/Registry.h
@@ -157,7 +157,7 @@ public:
public:
enum { MAX_OBJECT_NAME_SIZE = BUFSIZ,
- MAX_CONTEXT_NAME_SIZE = BUFSIZ };
+ MAX_CONTEXT_NAME_SIZE = MAXPATHLEN + 1 };
// Max sizes of names
// (Not too sure about this value)
diff --git a/ace/Registry_Name_Space.cpp b/ace/Registry_Name_Space.cpp
index b7d60d7354d..8199ea6f689 100644
--- a/ace/Registry_Name_Space.cpp
+++ b/ace/Registry_Name_Space.cpp
@@ -105,14 +105,28 @@ ACE_Registry_Name_Space::resolve (const ACE_WString &name,
ACE_WString &value,
char *&type)
{
- ACE_Registry::Object object;
- int result = this->context_.resolve (name.fast_rep (), object);
+ // This object will be used to query the size of the data.
+ // Note: The query_object.data will be null for this invocation.
+ ACE_Registry::Object query_object;
+ int result = this->context_.resolve (name.fast_rep (), query_object);
+ if (result != 0)
+ return result;
+
+ // Resize the value passed by the user
+ // Note: -1 is used because the size includes the null terminator
+ value.resize ((query_object.size () - 1) / sizeof (ACE_USHORT16));
+
+ // Represent new space as an ACE_Registry::Object
+ ACE_Registry::Object object ((void *) value.fast_rep (),
+ query_object.size (),
+ REG_SZ);
+
+ result = this->context_.resolve (name.fast_rep (), object);
+ if (object.size () != query_object.size ())
+ return -1;
if (result != 0)
return result;
- ACE_WString string ((ACE_USHORT16 *) object.data (),
- object.size () / sizeof (ACE_USHORT16));
- value = string;
return 0;
}
diff --git a/ace/Registry_Name_Space.h b/ace/Registry_Name_Space.h
index 6d0fa7b9807..5e0448babd2 100644
--- a/ace/Registry_Name_Space.h
+++ b/ace/Registry_Name_Space.h
@@ -16,11 +16,12 @@
#if !defined (ACE_REGISTRY_NAME_SPACE_H)
#define ACE_REGISTRY_NAME_SPACE_H
-#include "ace/Registry.h"
+#include "ace/OS.h"
#if (defined (ACE_WIN32) && defined (UNICODE))
// This only works on Win32 platforms when UNICODE is turned on
+#include "ace/Registry.h"
#include "ace/Naming_Context.h"
#include "ace/Name_Space.h"
diff --git a/ace/SString.cpp b/ace/SString.cpp
index 47c52efcf68..4b71db2c86b 100644
--- a/ace/SString.cpp
+++ b/ace/SString.cpp
@@ -521,6 +521,26 @@ ACE_WString::ACE_WString (const ACE_USHORT16 *s,
}
}
+// Constructor that allocates empty memory
+
+ACE_WString::ACE_WString (size_t len,
+ ACE_Allocator *alloc)
+ : allocator_ (alloc)
+{
+ ACE_TRACE ("ACE_WString::ACE_WString");
+
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Service_Config::alloc ();
+
+ this->len_ = len;
+ this->rep_ = (ACE_USHORT16 *) this->allocator_->malloc ((this->len_ + 1) * sizeof (ACE_USHORT16));
+
+ ACE_OS::memset (this->rep_, 0, len * sizeof (ACE_USHORT16));
+
+ // null terminate
+ this->rep_[this->len_] = 0;
+}
+
size_t
ACE_WString::length (void) const
{
@@ -570,6 +590,23 @@ ACE_WString::operator = (const ACE_WString &s)
}
}
+void
+ACE_WString::resize (size_t len)
+{
+ ACE_TRACE ("ACE_WString::resize");
+
+ // Only reallocate if we don't have enough space...
+ if (this->len_ < len)
+ {
+ this->allocator_->free (this->rep_);
+ this->rep_ = (ACE_USHORT16 *) this->allocator_->malloc ((len + 1) * sizeof (ACE_USHORT16));
+ }
+
+ this->len_ = len;
+ ACE_OS::memset (this->rep_, 0, this->len_ * sizeof (ACE_USHORT16));
+ this->rep_[this->len_] = 0;
+}
+
// Concat operator (does copy memory).
void
diff --git a/ace/SString.h b/ace/SString.h
index 7e17cba8bee..3e1bc8c462b 100644
--- a/ace/SString.h
+++ b/ace/SString.h
@@ -212,6 +212,10 @@ public:
// Constructor that copies <len> ACE_USHORT16's of <s> into dynamically
// allocated memory (will NUL terminate the result).
+ ACE_WString (size_t len, ACE_Allocator *allocator = 0);
+ // Constructor that dynamically allocates memory for <len> + 1
+ // ACE_USHORT16 characters. The newly created memory is set memset to 0.
+
ACE_WString (const ACE_WString &s);
// Copy constructor.
@@ -262,6 +266,12 @@ public:
static size_t wstrlen (const ACE_USHORT16 *);
// Computes the length of a "0" terminated ACE_USHORT16 *.
+ void resize (size_t len);
+ // This method is designed for high-performance. Please use with
+ // care ;-) If the current size of the string is less than <len>,
+ // the string is resized to the new length. The data is is zero'd
+ // out after this operation.
+
private:
ACE_Allocator *allocator_;
// Pointer to a memory allocator.