Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/102229

From BetaArchive Wiki

Overloading the __huge new Operator

Q102229

1.00 WINDOWS kbprg ---------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual C++ for Windows, version 1.0 ---------------------------------------------------------------------- When an application overloads the __huge version of operator new with C/C++ version 8.0 for MS-DOS, you must verify that the declaration properly specifies two parameters. Microsoft confirmed a problem using the __huge operator new in C/C++ version 7.0 for MS-DOS and documented the methods to work around the problem in the Microsoft Knowledge Base. For more information, please search on the following words: huge operator new MORE INFORMATION ================ An operator new that returns a huge pointer acts like an array allocator. It has two parameters: the number of elements to allocate and the size of each element. If the total size of the array is greater than 128K, the size of each element must be a power of 2. The correct declaration for the __huge version of operator new is as follows: void __huge *operator new(unsigned long elems, size_t size); Note that when calling new(), the first parameter must be a constant rather than a variable due to a code generation problem. Please see the following Knowledge Base article for a description of this problem: Q111754: BUG: __Huge New Operator Fails with Variable Size Sample Code ----------- /* * Compiler options needed: /AL /Od /Zi */ #include #include #include void __huge *operator new(unsigned long num, size_t size); void __huge *operator new(unsigned long num, size_t size) { cout << "Inside __huge new\n"; return _halloc(num, size); } void main() { int __huge *h_ptr; h_ptr = new __huge int[10000L]; if (h_ptr == NULL) cout << "Alloc failed\n"; delete h_ptr; } Additional reference words: kbinf 1.00 overload customizing KBCategory: kbprg KBSubcategory: CPPLngIss

Keywords : kb16bitonly
Issue type :
Technology : kbVCsearch kbAudDeveloper kbvc100


Last Reviewed: May 6, 2001
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.