| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights reserv
ed. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "wtf/PartitionAlloc.h" | 29 #include "wtf/PartitionAlloc.h" |
| 30 #include "wtf/Partitions.h" | 30 #include "wtf/Partitions.h" |
| 31 #include <string.h> | 31 #include <string.h> |
| 32 | 32 |
| 33 using namespace std; | 33 using namespace std; |
| 34 | 34 |
| 35 namespace WTF { | 35 namespace WTF { |
| 36 | 36 |
| 37 PassRefPtr<CStringBuffer> CStringBuffer::createUninitialized(size_t length) | 37 PassRefPtr<CStringBuffer> CStringBuffer::createUninitialized(size_t length) |
| 38 { | 38 { |
| 39 RELEASE_ASSERT(length < (numeric_limits<unsigned>::max() - sizeof(CStringBuf
fer))); | 39 CHECK_LT(length, numeric_limits<unsigned>::max() - sizeof(CStringBuffer)); |
| 40 | 40 |
| 41 // The +1 is for the terminating NUL character. | 41 // The +1 is for the terminating NUL character. |
| 42 size_t size = sizeof(CStringBuffer) + length + 1; | 42 size_t size = sizeof(CStringBuffer) + length + 1; |
| 43 CStringBuffer* stringBuffer = static_cast<CStringBuffer*>(Partitions::buffer
Malloc(size, WTF_HEAP_PROFILER_TYPE_NAME(CStringBuffer))); | 43 CStringBuffer* stringBuffer = static_cast<CStringBuffer*>(Partitions::buffer
Malloc(size, WTF_HEAP_PROFILER_TYPE_NAME(CStringBuffer))); |
| 44 return adoptRef(new (stringBuffer) CStringBuffer(length)); | 44 return adoptRef(new (stringBuffer) CStringBuffer(length)); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void CStringBuffer::operator delete(void* ptr) | 47 void CStringBuffer::operator delete(void* ptr) |
| 48 { | 48 { |
| 49 Partitions::bufferFree(ptr); | 49 Partitions::bufferFree(ptr); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 bool operator==(const CString& a, const char* b) | 122 bool operator==(const CString& a, const char* b) |
| 123 { | 123 { |
| 124 if (a.isNull() != !b) | 124 if (a.isNull() != !b) |
| 125 return false; | 125 return false; |
| 126 if (!b) | 126 if (!b) |
| 127 return true; | 127 return true; |
| 128 return !strcmp(a.data(), b); | 128 return !strcmp(a.data(), b); |
| 129 } | 129 } |
| 130 | 130 |
| 131 } // namespace WTF | 131 } // namespace WTF |
| OLD | NEW |