added the HeapMmgr class
This commit is contained in:
		| @ -26,24 +26,23 @@ | ||||
|  | ||||
| #include <qse/cmn/ExcMmgr.hpp> | ||||
| #include <stdlib.h> | ||||
| #include <stdio.h> | ||||
|  | ||||
|  | ||||
| ///////////////////////////////// | ||||
| QSE_BEGIN_NAMESPACE(QSE) | ||||
| ///////////////////////////////// | ||||
|  | ||||
|  | ||||
| void* ExcMmgr::allocMem (qse_size_t n)  | ||||
| { | ||||
| 	void* ptr = ::malloc (n); | ||||
| 	if (!ptr) QSE_THROW (Error); | ||||
| 	return ptr;  | ||||
| 	void* xptr = ::malloc (n); | ||||
| 	if (!xptr) QSE_THROW (MemoryError); | ||||
| 	return xptr;  | ||||
| } | ||||
|  | ||||
| void* ExcMmgr::reallocMem (void* ptr, qse_size_t n)  | ||||
| {  | ||||
| 	void* xptr = ::realloc (ptr, n);  | ||||
| 	if (!xptr) QSE_THROW (Error); | ||||
| 	if (!xptr) QSE_THROW (MemoryError); | ||||
| 	return xptr; | ||||
| } | ||||
|  | ||||
| @ -52,7 +51,7 @@ void ExcMmgr::freeMem (void* ptr) | ||||
| 	::free (ptr);  | ||||
| } | ||||
|  | ||||
| ExcMmgr* ExcMmgr::getDFL () | ||||
| ExcMmgr* ExcMmgr::getInstance () | ||||
| { | ||||
| 	static ExcMmgr DFL; | ||||
| 	return &DFL; | ||||
|  | ||||
| @ -141,7 +141,7 @@ if ENABLE_CXX | ||||
|  | ||||
| lib_LTLIBRARIES += libqsecmnxx.la | ||||
| libqsecmnxx_la_SOURCES = \ | ||||
| 	Mmgr.cpp StdMmgr.cpp ExcMmgr.cpp Mmged.cpp Mpool.cpp | ||||
| 	Mmgr.cpp StdMmgr.cpp ExcMmgr.cpp HeapMmgr.cpp Mmged.cpp Mpool.cpp | ||||
| libqsecmnxx_la_LDFLAGS = -version-info 1:0:0 -no-undefined | ||||
| libqsecmnxx_la_LIBADD =  | ||||
|  | ||||
|  | ||||
| @ -150,9 +150,9 @@ libqsecmn_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ | ||||
| 	$(libqsecmn_la_LDFLAGS) $(LDFLAGS) -o $@ | ||||
| libqsecmnxx_la_DEPENDENCIES = | ||||
| am__libqsecmnxx_la_SOURCES_DIST = Mmgr.cpp StdMmgr.cpp ExcMmgr.cpp \ | ||||
| 	Mmged.cpp Mpool.cpp | ||||
| 	HeapMmgr.cpp Mmged.cpp Mpool.cpp | ||||
| @ENABLE_CXX_TRUE@am_libqsecmnxx_la_OBJECTS = Mmgr.lo StdMmgr.lo \ | ||||
| @ENABLE_CXX_TRUE@	ExcMmgr.lo Mmged.lo Mpool.lo | ||||
| @ENABLE_CXX_TRUE@	ExcMmgr.lo HeapMmgr.lo Mmged.lo Mpool.lo | ||||
| libqsecmnxx_la_OBJECTS = $(am_libqsecmnxx_la_OBJECTS) | ||||
| libqsecmnxx_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ | ||||
| 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ | ||||
| @ -435,7 +435,7 @@ libqsecmn_la_SOURCES = alg-base64.c alg-rand.c alg-search.c alg-sort.c \ | ||||
| libqsecmn_la_LDFLAGS = -version-info 1:0:0 -no-undefined | ||||
| libqsecmn_la_LIBADD = $(SOCKET_LIBS) $(QUADMATH_LIBS) | ||||
| @ENABLE_CXX_TRUE@libqsecmnxx_la_SOURCES = \ | ||||
| @ENABLE_CXX_TRUE@	Mmgr.cpp StdMmgr.cpp ExcMmgr.cpp Mmged.cpp Mpool.cpp | ||||
| @ENABLE_CXX_TRUE@	Mmgr.cpp StdMmgr.cpp ExcMmgr.cpp HeapMmgr.cpp Mmged.cpp Mpool.cpp | ||||
|  | ||||
| @ENABLE_CXX_TRUE@libqsecmnxx_la_LDFLAGS = -version-info 1:0:0 -no-undefined | ||||
| @ENABLE_CXX_TRUE@libqsecmnxx_la_LIBADD =  | ||||
| @ -517,6 +517,7 @@ distclean-compile: | ||||
| 	-rm -f *.tab.c | ||||
|  | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ExcMmgr.Plo@am__quote@ | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HeapMmgr.Plo@am__quote@ | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Mmged.Plo@am__quote@ | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Mmgr.Plo@am__quote@ | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Mpool.Plo@am__quote@ | ||||
|  | ||||
| @ -25,7 +25,6 @@ | ||||
|  */ | ||||
|  | ||||
| #include <qse/cmn/Mmged.hpp> | ||||
| #include <qse/cmn/ExcMmgr.hpp> | ||||
|  | ||||
| ///////////////////////////////// | ||||
| QSE_BEGIN_NAMESPACE(QSE) | ||||
| @ -33,7 +32,7 @@ QSE_BEGIN_NAMESPACE(QSE) | ||||
|  | ||||
| Mmged::Mmged (Mmgr* mmgr) | ||||
| { | ||||
| 	if (!mmgr) mmgr = ExcMmgr::getDFL(); // TODO: use a different manager???? StdMmgr??? | ||||
| 	if (!mmgr) mmgr = Mmgr::getDFL(); | ||||
| 	this->mmgr = mmgr; | ||||
| } | ||||
| ///////////////////////////////// | ||||
|  | ||||
| @ -25,6 +25,8 @@ | ||||
|  */ | ||||
|  | ||||
| #include <qse/cmn/Mmgr.hpp> | ||||
| #include <qse/cmn/ExcMmgr.hpp> | ||||
| #include <qse/cmn/StdMmgr.hpp> | ||||
|  | ||||
| ///////////////////////////////// | ||||
| QSE_BEGIN_NAMESPACE(QSE) | ||||
| @ -45,6 +47,18 @@ void Mmgr::free_mem (mmgr_t* mmgr, void* ptr) | ||||
| 	((Mmgr*)mmgr->ctx)->freeMem (ptr); | ||||
| } | ||||
|  | ||||
| Mmgr* Mmgr::dfl_mmgr = ExcMmgr::getInstance(); | ||||
|  | ||||
| Mmgr* Mmgr::getDFL () | ||||
| { | ||||
| 	return Mmgr::dfl_mmgr; | ||||
| } | ||||
|  | ||||
| void Mmgr::setDFL (Mmgr* mmgr) | ||||
| { | ||||
| 	Mmgr::dfl_mmgr = mmgr; | ||||
| } | ||||
|  | ||||
| ///////////////////////////////// | ||||
| QSE_END_NAMESPACE(QSE) | ||||
| ///////////////////////////////// | ||||
|  | ||||
| @ -47,7 +47,7 @@ void StdMmgr::freeMem (void* ptr) | ||||
| 	::free (ptr);  | ||||
| } | ||||
|  | ||||
| StdMmgr* StdMmgr::getDFL () | ||||
| StdMmgr* StdMmgr::getInstance () | ||||
| { | ||||
| 	static StdMmgr DFL; | ||||
| 	return &DFL; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user