1. 17 Feb, 2016 1 commit
    • Filip Roséen's avatar
      nothrow new in cases where it maches intent · 1bed74fe
      Filip Roséen authored
      I wrote a hackish script to locate instances where new can throw
      but where the original author has assumed that it will return
      nullptr when there is a memory allocation problem.
      
      In short, cases such as `ptr = new T; if (ptr) ...` has now
      been changed to `ptr = new (std::nothrow) T; if (ptr) ...`.
      
      Since a throwing `new` will always yield a non-nullptr pointer,
      code that follows similar patterns to the previous example are
      therefor redundant.
      
      Example (from modules/access/dshow/filter.cpp):
      
          *ppEnum = new CaptureEnumMediaTypes( p_input, p_pin, this );
      
          if( *ppEnum == NULL )
            return E_OUTOFMEMORY; // unreachable, new will never return NULL
      
      Fixed:
      
          *ppEnum = new (std::nothrow) CaptureEnumMediaTypes( p_input, p_pin, this );
      
          if( *ppEnum == NULL )
            return E_OUTOFMEMORY;
      Signed-off-by: Hugo Beauzée-Luyssen's avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
      1bed74fe
  2. 16 Feb, 2016 3 commits
  3. 15 Feb, 2016 11 commits
  4. 14 Feb, 2016 6 commits
  5. 13 Feb, 2016 10 commits
  6. 12 Feb, 2016 9 commits