Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: third_party/WebKit/Source/platform/wtf/text/CString.cpp

Issue 2833123002: Replace ASSERT_NOT_REACHED, and RELEASE_ASSERT in platform/wtf (Closed)
Patch Set: wtf Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights 2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 19 matching lines...) Expand all
30 #include "platform/wtf/allocator/Partitions.h" 30 #include "platform/wtf/allocator/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<CStringImpl> CStringImpl::CreateUninitialized(size_t length, 37 PassRefPtr<CStringImpl> CStringImpl::CreateUninitialized(size_t length,
38 char*& data) { 38 char*& data) {
39 // TODO(esprehn): This doesn't account for the NUL. 39 // TODO(esprehn): This doesn't account for the NUL.
40 RELEASE_ASSERT(length < 40 CHECK_LT(length, (numeric_limits<unsigned>::max() - sizeof(CStringImpl)));
41 (numeric_limits<unsigned>::max() - sizeof(CStringImpl)));
42 41
43 // The +1 is for the terminating NUL character. 42 // The +1 is for the terminating NUL character.
44 size_t size = sizeof(CStringImpl) + length + 1; 43 size_t size = sizeof(CStringImpl) + length + 1;
45 CStringImpl* buffer = static_cast<CStringImpl*>( 44 CStringImpl* buffer = static_cast<CStringImpl*>(
46 Partitions::BufferMalloc(size, WTF_HEAP_PROFILER_TYPE_NAME(CStringImpl))); 45 Partitions::BufferMalloc(size, WTF_HEAP_PROFILER_TYPE_NAME(CStringImpl)));
47 data = reinterpret_cast<char*>(buffer + 1); 46 data = reinterpret_cast<char*>(buffer + 1);
48 data[length] = '\0'; 47 data[length] = '\0';
49 return AdoptRef(new (buffer) CStringImpl(length)); 48 return AdoptRef(new (buffer) CStringImpl(length));
50 } 49 }
51 50
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 ostream.setf(std::ios::uppercase); 118 ostream.setf(std::ios::uppercase);
120 ostream << (character & 0xff); 119 ostream << (character & 0xff);
121 } 120 }
122 break; 121 break;
123 } 122 }
124 } 123 }
125 return ostream << '"'; 124 return ostream << '"';
126 } 125 }
127 126
128 } // namespace WTF 127 } // namespace WTF
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698