changed the position of the mmgr parameter in some constructors.

removed StdMmgr::getInstance() and initialized the default mmgr inside Mmgr::getDFL() to work around an issue related to c++ initialization order across translation units
This commit is contained in:
2018-10-31 10:40:25 +00:00
parent b01cf731ca
commit efc34cdd69
26 changed files with 87 additions and 88 deletions

View File

@ -73,8 +73,8 @@ typedef QSE::Array<PosStr> StrArray;
int main ()
{
//StrArray h (QSE_NULL, 100);
StrArray h (QSE_NULL, 15);
//StrArray h (100);
StrArray h (15);
char buf[20];
for (int i = 0; i < 20; i++)

View File

@ -93,8 +93,8 @@ printf ("================\n");
printf ("----------------------\n");
#endif
//QSE::HashList<T> h (mmgr, 1000, 75, 1000);
QSE::HashList<T> h (mmgr, 1000, 75, 500);
//QSE::HashList<T> h (1000, 75, 1000, mmgr);
QSE::HashList<T> h (1000, 75, 500, mmgr);
for (int i = 0; i < 1000; i++)
{
T x(i);
@ -102,7 +102,7 @@ for (int i = 0; i < 1000; i++)
}
printf ("h.getSize() => %d\n", (int)h.getSize());
QSE::HashList<T> h2 (mmgr, 1000, 75, 700);
QSE::HashList<T> h2 (1000, 75, 700, mmgr);
h2 = h;
for (QSE::HashList<T>::Iterator it = h2.getIterator(); it.isLegit(); it++)

View File

@ -71,10 +71,10 @@ int main ()
{
// qse_open_stdsios ();
QSE::HeapMmgr heap_mmgr (QSE::Mmgr::getDFL(), 3000000);
QSE::HeapMmgr heap_mmgr (3000000, QSE::Mmgr::getDFL());
//QSE::HashTable<int,int,IntHasher> int_table (&heap_mmgr, 1000);
IntTable int_table (NULL, IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 1000);
//IntTable int_table (NULL, IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 0);
IntTable int_table (IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 1000);
//IntTable int_table (IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 0);
printf ("----------\n");
for (int i = 0; i < 100; i++)
{
@ -112,8 +112,8 @@ printf ("----------\n");
printf ("%d\n", int_table[9990]);
*/
//Str1Table s1 (NULL, IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 1000);
Str1Table s1 (NULL, IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 0);
//Str1Table s1 (IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 1000);
Str1Table s1 (IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 0);
//Str1Table s1;
s1.insert ("hello", 20);
s1.insert ("hello", 20);
@ -150,8 +150,8 @@ printf ("----------\n");
printf ("------------------\n");
{
Str1Table s11 (&heap_mmgr, IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 0);
//Str1Table s11 (NULL, IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 200);
Str1Table s11 (IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 0, &heap_mmgr);
//Str1Table s11 (IntTable::DEFAULT_CAPACITY, IntTable::DEFAULT_LOAD_FACTOR, 200);
//Str1Table s11;
for (int i = 0; i < 100; i++)

View File

@ -22,7 +22,7 @@ typedef QSE::RedBlackTree<IntPair> IntTree;
int main ()
{
IntTree t (0, 10000);
IntTree t (10000, QSE_NULL);
//IntTree t (0);
for (int i = 0; i < 20 ; i++)
@ -54,7 +54,7 @@ int main ()
printf ("------------------\n");
t.insert (IntPair(99, 999));
t.insert (IntPair(88, 888));
//IntTree y (QSE_NULL, 5);
//IntTree y (5, QSE_NULL);
x = t;
for (it = x.getConstIterator(); it.isLegit(); ++it)
{

View File

@ -39,10 +39,10 @@ int main ()
{
// qse_open_stdsios ();
QSE::HeapMmgr heap_mmgr (QSE::Mmgr::getDFL(), 3000000);
//QSE::RedBlackTable<int,int,IntHasher> int_table (&heap_mmgr, 1000);
IntTable int_table (NULL, 1000);
//IntTable int_table (NULL, 0);
QSE::HeapMmgr heap_mmgr (3000000, QSE::Mmgr::getDFL());
//QSE::RedBlackTable<int,int,IntHasher> int_table (1000, &heap_mmgr);
IntTable int_table (1000, QSE_NULL);
//IntTable int_table (0, QSE_NULL);
printf ("----------\n");
for (int i = 0; i < 100; i++)
{
@ -80,8 +80,8 @@ printf ("----------\n");
printf ("%d\n", int_table[9990]);
*/
//Str1Table s1 (NULL, 1000);
Str1Table s1 (NULL, 0);
//Str1Table s1 (1000, QSE_NULL);
Str1Table s1 (0, QSE_NULL);
//Str1Table s1;
s1.insert ("hello", 20);
s1.insert ("hello", 20);
@ -118,8 +118,8 @@ printf ("----------\n");
printf ("------------------\n");
{
Str1Table s11 (&heap_mmgr, 0);
//Str1Table s11 (NULL, 200);
Str1Table s11 (0, &heap_mmgr);
//Str1Table s11 (200, QSE_NULL);
//Str1Table s11;
for (int i = 0; i < 100; i++)

View File

@ -28,7 +28,7 @@ struct destroy_x_in_mmgr
int main ()
{
QSE::HeapMmgr heap_mmgr (QSE::Mmgr::getDFL(), 30000);
QSE::HeapMmgr heap_mmgr (30000, QSE::Mmgr::getDFL());
{
QSE::ScopedPtr<X> x1 (new X);

View File

@ -45,8 +45,8 @@ struct destroy_x_in_mmgr
int f2 ()
{
QSE::HeapMmgr heap_mmgr (QSE::Mmgr::getDFL(), 30000);
QSE::HeapMmgr heap_mmgr_2 (QSE::Mmgr::getDFL(), 30000);
QSE::HeapMmgr heap_mmgr (30000, QSE::Mmgr::getDFL());
QSE::HeapMmgr heap_mmgr_2 (30000, QSE::Mmgr::getDFL());
QSE::SharedPtr<X> y (new X(1));
QSE::SharedPtr<X,QSE::SharedPtrMmgrDeleter<X> > k (&heap_mmgr);

View File

@ -6,7 +6,7 @@
void t1 ()
{
QSE::HeapMmgr heap_mmgr (QSE::Mmgr::getDFL(), 30000);
QSE::HeapMmgr heap_mmgr (30000, QSE::Mmgr::getDFL());
QSE::String* z = new QSE::String();
{

View File

@ -99,7 +99,7 @@ protected:
static int test1()
{
QSE::HeapMmgr heap_mmgr (QSE::Mmgr::getDFL(), 30000);
QSE::HeapMmgr heap_mmgr (30000, QSE::Mmgr::getDFL());
MyApp app (&heap_mmgr);
MyApp app2 (&heap_mmgr);

View File

@ -62,7 +62,7 @@ static QSE::TcpServerF<ClientHandler>* g_server;
static int test1 (void)
{
QSE::HeapMmgr heap_mmgr (QSE::Mmgr::getDFL(), 30000);
QSE::HeapMmgr heap_mmgr (30000, QSE::Mmgr::getDFL());
#if defined(QSE_LANG_CPP11)
QSE::TcpServerL<int(QSE::TcpServer::Worker*)> server (

View File

@ -18,7 +18,7 @@ static int g_stopreq = 0;
static qse_ntime_t sleep_interval = { 1, 0 };
QSE::HeapMmgr g_heap_mmgr (QSE::Mmgr::getDFL(), 30000);
QSE::HeapMmgr g_heap_mmgr (30000, QSE::Mmgr::getDFL());
class MyThread: public QSE::Thread
{

View File

@ -19,7 +19,7 @@
static int g_stopreq = 0;
static qse_ntime_t sleep_interval = { 1, 0 };
QSE::HeapMmgr g_heap_mmgr (QSE::Mmgr::getDFL(), 30000);
QSE::HeapMmgr g_heap_mmgr (30000, QSE::Mmgr::getDFL());
struct rq_data_t
{