Ignore:
Timestamp:
Aug 10, 2009, 12:42:10 PM (16 years ago)
Author:
Darin Adler
Message:

FastMalloc.h has cross-platform code but marked as WinCE-only
https://bugs.webkit.org/show_bug.cgi?id=28160

Patch by Darin Adler <Darin Adler> on 2009-08-10
Reviewed by Mark Rowe.

1) The support for nothrow was inside #if PLATFORM(WINCE) even though it is

not platform-specific.

2) The code tried to override operator delete nothrow, which does not exist.
3) The code in the header checks the value of USE_SYSTEM_MALLOC, but the code

in FastMalloc.cpp checks only if the macro is defined.

  • wtf/FastMalloc.h: See above.
  • wtf/FastMalloc.cpp: Ditto.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/FastMalloc.h

    r46180 r46999  
    11/*
    2  *  Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     2 *  Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
    33 *
    44 *  This library is free software; you can redistribute it and/or
     
    2929
    3030    // These functions call CRASH() if an allocation fails.
    31     void* fastMalloc(size_t n);
    32     void* fastZeroedMalloc(size_t n);
    33     void* fastCalloc(size_t n_elements, size_t element_size);
    34     void* fastRealloc(void* p, size_t n);
     31    void* fastMalloc(size_t);
     32    void* fastZeroedMalloc(size_t);
     33    void* fastCalloc(size_t numElements, size_t elementSize);
     34    void* fastRealloc(void*, size_t);
    3535
    36     // These functions return NULL if an allocation fails.
    37     void* tryFastMalloc(size_t n);
    38     void* tryFastZeroedMalloc(size_t n);
    39     void* tryFastCalloc(size_t n_elements, size_t element_size);
    40     void* tryFastRealloc(void* p, size_t n);
     36    // These functions return 0 if an allocation fails.
     37    void* tryFastMalloc(size_t);
     38    void* tryFastZeroedMalloc(size_t);
     39    void* tryFastCalloc(size_t numElements, size_t elementSize);
     40    void* tryFastRealloc(void*, size_t);
    4141
    42     void fastFree(void* p);
     42    void fastFree(void*);
    4343
    4444#ifndef NDEBUG   
     
    173173#endif
    174174
    175 #ifndef _CRTDBG_MAP_ALLOC
     175#if !defined(_CRTDBG_MAP_ALLOC) && !(defined(USE_SYSTEM_MALLOC) && USE_SYSTEM_MALLOC)
    176176
    177 #if !defined(USE_SYSTEM_MALLOC) || !(USE_SYSTEM_MALLOC)
    178 WTF_PRIVATE_INLINE void* operator new(size_t s) { return fastMalloc(s); }
     177// The nothrow functions here are actually not all that helpful, because fastMalloc will
     178// call CRASH() rather than returning 0, and returning 0 is what nothrow is all about.
     179// But since WebKit code never uses exceptions or nothrow at all, this is probably OK.
     180// Long term we will adopt FastAllocBase.h everywhere, and and replace this with
     181// debug-only code to make sure we don't use the system malloc via the default operator
     182// new by accident.
     183
     184WTF_PRIVATE_INLINE void* operator new(size_t size) { return fastMalloc(s); }
     185WTF_PRIVATE_INLINE void* operator new(size_t size, const std::nothrow_t&) throw() { return fastMalloc(size); }
    179186WTF_PRIVATE_INLINE void operator delete(void* p) { fastFree(p); }
    180 WTF_PRIVATE_INLINE void* operator new[](size_t s) { return fastMalloc(s); }
     187WTF_PRIVATE_INLINE void* operator new[](size_t size) { return fastMalloc(size); }
     188WTF_PRIVATE_INLINE void* operator new[](size_t size, const std::nothrow_t&) throw() { return fastMalloc(size); }
    181189WTF_PRIVATE_INLINE void operator delete[](void* p) { fastFree(p); }
    182190
    183 #if PLATFORM(WINCE)
    184 WTF_PRIVATE_INLINE void* operator new(size_t s, const std::nothrow_t&) throw() { return fastMalloc(s); }
    185 WTF_PRIVATE_INLINE void operator delete(void* p, const std::nothrow_t&) throw() { fastFree(p); }
    186 WTF_PRIVATE_INLINE void* operator new[](size_t s, const std::nothrow_t&) throw() { return fastMalloc(s); }
    187 WTF_PRIVATE_INLINE void operator delete[](void* p, const std::nothrow_t&) throw() { fastFree(p); }
    188 #endif
    189191#endif
    190192
    191 #endif // _CRTDBG_MAP_ALLOC
    192 
    193193#endif /* WTF_FastMalloc_h */
Note: See TracChangeset for help on using the changeset viewer.