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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 399 |
400 template <typename T, int kSize> | 400 template <typename T, int kSize> |
401 class EmbeddedVector : public Vector<T> { | 401 class EmbeddedVector : public Vector<T> { |
402 public: | 402 public: |
403 EmbeddedVector() : Vector<T>(buffer_, kSize) { } | 403 EmbeddedVector() : Vector<T>(buffer_, kSize) { } |
404 private: | 404 private: |
405 T buffer_[kSize]; | 405 T buffer_[kSize]; |
406 }; | 406 }; |
407 | 407 |
408 | 408 |
| 409 template <typename T> |
| 410 class ScopedVector : public Vector<T> { |
| 411 public: |
| 412 ScopedVector(int length) : Vector<T>(NewArray<T>(length), length) { } |
| 413 ~ScopedVector() { |
| 414 DeleteArray(this->start()); |
| 415 } |
| 416 }; |
| 417 |
| 418 |
409 inline Vector<const char> CStrVector(const char* data) { | 419 inline Vector<const char> CStrVector(const char* data) { |
410 return Vector<const char>(data, strlen(data)); | 420 return Vector<const char>(data, strlen(data)); |
411 } | 421 } |
412 | 422 |
413 inline Vector<char> MutableCStrVector(char* data) { | 423 inline Vector<char> MutableCStrVector(char* data) { |
414 return Vector<char>(data, strlen(data)); | 424 return Vector<char>(data, strlen(data)); |
415 } | 425 } |
416 | 426 |
417 inline Vector<char> MutableCStrVector(char* data, int max) { | 427 inline Vector<char> MutableCStrVector(char* data, int max) { |
418 int length = strlen(data); | 428 int length = strlen(data); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 #endif | 541 #endif |
532 while (dest < limit) { | 542 while (dest < limit) { |
533 *dest++ = static_cast<sinkchar>(*src++); | 543 *dest++ = static_cast<sinkchar>(*src++); |
534 } | 544 } |
535 } | 545 } |
536 | 546 |
537 | 547 |
538 } } // namespace v8::internal | 548 } } // namespace v8::internal |
539 | 549 |
540 #endif // V8_UTILS_H_ | 550 #endif // V8_UTILS_H_ |
OLD | NEW |