diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-12-01 06:19:11 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-12-01 06:19:11 +0000 |
commit | cd136206c84738a63c0f67e29eb3856c7798c29b (patch) | |
tree | 83a385977408b3da5041c1746b16e4820615510e /STL/defalloc.h | |
parent | 8407bcd88835f9a2a38a9485581e91cee4613477 (diff) | |
download | ATCD-cd136206c84738a63c0f67e29eb3856c7798c29b.tar.gz |
*** empty log message ***
Diffstat (limited to 'STL/defalloc.h')
-rw-r--r-- | STL/defalloc.h | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/STL/defalloc.h b/STL/defalloc.h index 56c5e692e96..c0e2e04998d 100644 --- a/STL/defalloc.h +++ b/STL/defalloc.h @@ -39,8 +39,8 @@ inline T* allocate(ptrdiff_t size, T*) { set_new_handler(0); T* tmp = (T*)(::operator new((size_t)(size * sizeof(T)))); if (tmp == 0) { - cerr << "out of memory" << endl; - exit(1); + cerr << "out of memory" << endl; + exit(1); } return tmp; } @@ -54,26 +54,47 @@ namespace std { * End change by Terris */ +/* +* Added by Terris (#if out code) + */ +#if 0 +/* + * Added by Terris End + */ template <class T> inline T* allocate(int size, T*) { - set_new_handler(0); - T* tmp = (T*)(::operator new((unsigned int)(size * sizeof(T)))); - if (tmp == 0) { - cerr << "out of memory" << endl; - exit(1); + set_new_handler(0); + T* tmp = (T*)(::operator new((unsigned int)(size * sizeof(T)))); + if (tmp == 0) { + cerr << "out of memory" << endl; + exit(1); } return tmp; } +/* + * Added by Terris + */ +#endif +/* + * Added by Terris End + */ template <class T> -inline T* allocate(long size, T*) { - set_new_handler(0); - T* tmp = (T*)(::operator new((unsigned long)(size * sizeof(T)))); - if (tmp == 0) { - cerr << "out of memory" << endl; - exit(1); - } - return tmp; +inline T* allocate(int size, T*) { // Changed by Terris -- was long. +/* + * Begin Change by Terris + */ +// set_new_handler(0); +// T* tmp = (T*)(::operator new((unsigned long)(size * sizeof(T)))); +// if (tmp == 0) { +// cerr << "out of memory" << endl; +// exit(1); +// } +// return tmp; +/* + * End Change by Terris + */ + return (T*)(::operator new((unsigned long)(size * sizeof(T)))); } template <class T> @@ -156,26 +177,18 @@ public: typedef ptrdiff_t difference_type; pointer allocate(size_type n) { - return std::allocate((difference_type)n, (pointer)0); + return std::allocate((difference_type)n, (pointer)0); } void deallocate(pointer p) { std::deallocate(p); } pointer address(reference x) { return (pointer)&x; } const_pointer const_address(const_reference x) { - return (const_pointer)&x; - } - /* - size_type init_page_size() { - return max(size_type(1), size_type(4096/sizeof(T))); - } - size_type max_size() const { - return max(size_type(1), size_type(UINT_MAX/sizeof(T))); + return (const_pointer)&x; } - */ size_type init_page_size() { - return size_type(4096/sizeof(T)); + return max(size_type(1), size_type(4096/sizeof(T))); } size_type max_size() const { - return size_type(UINT_MAX/sizeof(T)); + return max(size_type(1), size_type(UINT_MAX/sizeof(T))); } }; |