OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 public: | 50 public: |
51 ~HeapStringAllocator() { DeleteArray(space_); } | 51 ~HeapStringAllocator() { DeleteArray(space_); } |
52 char* allocate(unsigned bytes); | 52 char* allocate(unsigned bytes); |
53 char* grow(unsigned* bytes); | 53 char* grow(unsigned* bytes); |
54 private: | 54 private: |
55 char* space_; | 55 char* space_; |
56 }; | 56 }; |
57 | 57 |
58 | 58 |
59 // Allocator for use when no new c++ heap allocation is allowed. | 59 // Allocator for use when no new c++ heap allocation is allowed. |
60 // Allocates all space up front and does no allocation while building | 60 // Given a preallocated buffer up front and does no allocation while |
61 // message. | 61 // building message. |
62 class NoAllocationStringAllocator: public StringAllocator { | 62 class NoAllocationStringAllocator: public StringAllocator { |
63 public: | 63 public: |
64 explicit NoAllocationStringAllocator(unsigned bytes); | |
65 NoAllocationStringAllocator(char* memory, unsigned size); | 64 NoAllocationStringAllocator(char* memory, unsigned size); |
66 char* allocate(unsigned bytes) { return space_; } | 65 char* allocate(unsigned bytes) { return space_; } |
67 char* grow(unsigned* bytes); | 66 char* grow(unsigned* bytes); |
68 private: | 67 private: |
69 unsigned size_; | 68 unsigned size_; |
70 char* space_; | 69 char* space_; |
71 }; | 70 }; |
72 | 71 |
73 | 72 |
74 class FmtElm { | 73 class FmtElm { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 bool full() const { return (capacity_ - length_) == 1; } | 188 bool full() const { return (capacity_ - length_) == 1; } |
190 int space() const { return capacity_ - length_; } | 189 int space() const { return capacity_ - length_; } |
191 | 190 |
192 DISALLOW_IMPLICIT_CONSTRUCTORS(StringStream); | 191 DISALLOW_IMPLICIT_CONSTRUCTORS(StringStream); |
193 }; | 192 }; |
194 | 193 |
195 | 194 |
196 } } // namespace v8::internal | 195 } } // namespace v8::internal |
197 | 196 |
198 #endif // V8_STRING_STREAM_H_ | 197 #endif // V8_STRING_STREAM_H_ |
OLD | NEW |