summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authornanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-04-22 20:27:03 +0000
committernanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-04-22 20:27:03 +0000
commit45927c4b45ee2535af8af97f60f47899b133cfae (patch)
tree8ed64d24698528d398e2758299bf8309e742aed4 /tests
parent6d5b2f2aa69efa61c2d2c048eadca4dfd07e7bf7 (diff)
downloadATCD-45927c4b45ee2535af8af97f60f47899b133cfae.tar.gz
ChangeLogTag:Mon Apr 22 15:20:02 2002 Nanbor Wang <nanbor@cs.wustl.edu>
Diffstat (limited to 'tests')
-rw-r--r--tests/DLL_Test.cpp13
-rw-r--r--tests/DLL_Test.h6
-rw-r--r--tests/DLL_Test_Impl.cpp15
-rw-r--r--tests/DLL_Test_Impl.h6
4 files changed, 30 insertions, 10 deletions
diff --git a/tests/DLL_Test.cpp b/tests/DLL_Test.cpp
index 7619bd5bf54..87159629128 100644
--- a/tests/DLL_Test.cpp
+++ b/tests/DLL_Test.cpp
@@ -19,6 +19,7 @@
#include "test_config.h"
#include "DLL_Test.h"
#include "ace/DLL.h"
+#include "ace/Auto_Ptr.h"
#include "ace/ACE.h"
ACE_RCSID(tests, DLL_Test, "$Id$")
@@ -86,7 +87,7 @@ ACE_TMAIN (int, ACE_TCHAR *[])
dll.error ()),
-1);
- Hello *my_hello = factory ();
+ auto_ptr<Hello> my_hello (factory ());
// Make the method calls, as the object pointer is available.
my_hello->say_hello ();
@@ -102,8 +103,6 @@ ACE_TMAIN (int, ACE_TCHAR *[])
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Result for malloc_info(): %s\n"), malloc_str));
ACE_OS_Memory::free (malloc_str);
- my_hello->destroy ();
-
#else
ACE_ERROR ((LM_INFO,
ACE_TEXT ("Dynamically Linkable Libraries not supported on this platform\n")));
@@ -112,3 +111,11 @@ ACE_TMAIN (int, ACE_TCHAR *[])
ACE_END_TEST;
return 0;
}
+
+#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
+template class auto_ptr <Hello>;
+template class ACE_Auto_Basic_Ptr <Hello>;
+#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
+#pragma instantiate auto_ptr <Hello>
+#pragma instantiate ACE_Auto_Basic_Ptr <Hello>
+#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/tests/DLL_Test.h b/tests/DLL_Test.h
index 86ff15165be..25b68fe2a0f 100644
--- a/tests/DLL_Test.h
+++ b/tests/DLL_Test.h
@@ -47,12 +47,6 @@ public:
virtual ACE_TCHAR *malloc_info (void) = 0;
//@}
-
- void destroy (void)
- {
- ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Hello::destroy() \n")));
- delete this;
- }
};
#endif /* ACE_TESTS_DLL_TEST_H */
diff --git a/tests/DLL_Test_Impl.cpp b/tests/DLL_Test_Impl.cpp
index 9be1224df95..5e98b5d58d3 100644
--- a/tests/DLL_Test_Impl.cpp
+++ b/tests/DLL_Test_Impl.cpp
@@ -54,6 +54,19 @@ Hello_Impl::malloc_info (void)
return ACE_OS_String::strdup (ACE_TEXT ("Hello_Impl::new_info() allocated by ACE_OS_Memory::malloc()"));
}
+void *
+Hello_Impl::operator new (size_t bytes)
+{
+ ACE_DEBUG ((LM_INFO, "Hello_Impl::new\n"));
+ return ::new char[bytes];
+}
+void
+Hello_Impl::operator delete (void *ptr)
+{
+ ACE_DEBUG ((LM_INFO, "Hello_Impl::delete\n"));
+ delete [] ((char *) ptr);
+}
+
extern "C" ACE_Svc_Export Hello *
get_hello (void)
{
@@ -62,7 +75,7 @@ get_hello (void)
ACE_NEW_RETURN (hello,
Hello_Impl,
NULL);
-
+
return hello;
}
diff --git a/tests/DLL_Test_Impl.h b/tests/DLL_Test_Impl.h
index 21f3e2322f4..8478ce8916c 100644
--- a/tests/DLL_Test_Impl.h
+++ b/tests/DLL_Test_Impl.h
@@ -46,6 +46,12 @@ public:
ACE_TCHAR *malloc_info (void);
// Uses ACE_OS_Memory::malloc() to allocate the returned string.
+
+ // Overload the new/delete opertors so the object will be
+ // created/deleted using the memory allocator associated with the
+ // DLL/SO.
+ void *operator new (size_t bytes);
+ void operator delete (void *ptr);
};
#endif /* ACE_TESTS_DLL_TEST_IMPL_H */