patch-Array_h 798 B

123456789101112131415161718192021222324252627
  1. $OpenBSD: patch-Array_h,v 1.2 2012/12/12 14:58:00 dcoppa Exp $
  2. --- Array.h.orig Wed Dec 5 17:20:19 2012
  3. +++ Array.h Wed Dec 5 17:21:33 2012
  4. @@ -32,18 +32,18 @@ class Array
  5. Array( int n, const T* d ) : m_data(NULL), m_size(0), m_capacity(0)
  6. {
  7. - if ( n ) {
  8. + if ( n > 0 ) {
  9. capacity( n );
  10. - memcpy( m_data, d, n * sizeof(T) );
  11. + if ( m_data ) memcpy( m_data, d, n * sizeof(T) );
  12. m_size = n;
  13. }
  14. }
  15. Array( const Array& other ) : m_data(NULL), m_size(0), m_capacity(0)
  16. {
  17. - if ( other.size() ) {
  18. + if ( other.size() > 0 ) {
  19. capacity( other.size() );
  20. - memcpy( m_data, other.m_data, other.size() * sizeof(T) );
  21. + if ( m_data ) memcpy( m_data, other.m_data, other.size() * sizeof(T) );
  22. m_size = other.size();
  23. }
  24. }