;; Most symbols in the google-perftools dll are exported via ;; __declspec(dllexport). However, we can't do that for the memory ;; allocation routines we override (malloc, free, new), because those ;; already have an export spec in msvcrt.dll. In particular, they're ;; already declared internally in a header that exists in the ;; compiler's own static data, and there's no way to override ;; inclusion of that header. Since that header doesn't declare these ;; functoin dllexport, we can't redeclare them dllexport. Therefore, ;; we have to put any export decorations either here, or nowhere. ;; ;; Apparently, for malloc, free, and realloc, the right thing to do is ;; to put the export decorations nowhere: I guess msvcrt already does ;; something (I don't know what) that lets us override these functions ;; just by declaring our own version, without any need to export. ;; ;; However, for new and delete, the right thing to do is to export the ;; symbol here, in a .def file. We export the 4 versions of new and ;; delete that we override: ;; ??2@YAPAXI@Z (void * __cdecl operator new(unsigned int)) ;; ??3@YAXPAX@Z (void __cdecl operator delete(void *)) ;; ??_U@YAPAXI@Z (void * __cdecl operator new[](unsigned int)) ;; ??_V@YAXPAX@Z (void __cdecl operator delete[](void *)) ;; ??2@YAPAXIABUnothrow_t@std@@@Z (void * __cdecl operator new(unsigned int,struct std::nothrow_t const &)) ;; ??3@YAXPAXABUnothrow_t@std@@@Z (void __cdecl operator delete(void *,struct std::nothrow_t const &)) ;; ??_U@YAPAXIABUnothrow_t@std@@@Z (void * __cdecl operator new[](unsigned int,struct std::nothrow_t const &)) ;; ??_V@YAXPAXABUnothrow_t@std@@@Z (void __cdecl operator delete[](void *,struct std::nothrow_t const &)) ;; ;; (The first field is the mangled name, and the stuff in parens is ;; the unmangled name. Mangling can change from compiler-version to ;; compiler-version; the mangling above is good for at least VC++ 7.1 ;; and VC++ 8.0.) ;; ;; To figure out the mangled names, I compiled tcmalloc.obj ;; (tcmalloc.cc is the file that overrides these operators), and ran ;; "dumpbin /symbols" on tcmalloc.obj. I then did a grep (in unix :-) ) ;; over the output, looking for "operator". This showed the 8 ;; operator new and operator delete calls in tcmalloc.cc, plus a ;; placement new and placement delete that I ignored. ;; ;; Finally, for the memory-allocation routines that tcmalloc defines ;; but windows doesn't -- cfree, posix_memalign, etc -- I *could* put ;; a dllexport in the .h file where I declare them, since there's no ;; windows declaration to worry about. But I put them here instead, ;; partly to avoid the extra verbiage in the source code, and partly ;; to keep all the export info for the memory-allocation functions ;; together. EXPORTS ??2@YAPAXI@Z ??3@YAXPAX@Z ??_U@YAPAXI@Z ??_V@YAXPAX@Z ??2@YAPAXIABUnothrow_t@std@@@Z ??3@YAXPAXABUnothrow_t@std@@@Z ??_U@YAPAXIABUnothrow_t@std@@@Z ??_V@YAXPAXABUnothrow_t@std@@@Z cfree posix_memalign memalign valloc pvalloc