Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 32bd38f

Browse filesBrowse files
joyeecheungtargos
authored andcommitted
src: make util.h self-containted
Before it depended on util-inl.h. Fix it by moving MaybeStackBuffer::AllocateSufficientStorage() into util-inl.h PR-URL: #46817 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 56dbb15 commit 32bd38f
Copy full SHA for 32bd38f

File tree

Expand file treeCollapse file tree

2 files changed

+17
-13
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+17
-13
lines changed
Open diff view settings
Collapse file

‎src/util-inl.h‎

Copy file name to clipboardExpand all lines: src/util-inl.h
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,22 @@ SlicedArguments::SlicedArguments(
510510
(*this)[i] = args[i + start];
511511
}
512512

513+
template <typename T, size_t kStackStorageSize>
514+
void MaybeStackBuffer<T, kStackStorageSize>::AllocateSufficientStorage(
515+
size_t storage) {
516+
CHECK(!IsInvalidated());
517+
if (storage > capacity()) {
518+
bool was_allocated = IsAllocated();
519+
T* allocated_ptr = was_allocated ? buf_ : nullptr;
520+
buf_ = Realloc(allocated_ptr, storage);
521+
capacity_ = storage;
522+
if (!was_allocated && length_ > 0)
523+
memcpy(buf_, buf_st_, length_ * sizeof(buf_[0]));
524+
}
525+
526+
length_ = storage;
527+
}
528+
513529
template <typename T, size_t S>
514530
ArrayBufferViewContents<T, S>::ArrayBufferViewContents(
515531
v8::Local<v8::Value> value) {
Collapse file

‎src/util.h‎

Copy file name to clipboardExpand all lines: src/util.h
+1-13Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -412,19 +412,7 @@ class MaybeStackBuffer {
412412
// This method can be called multiple times throughout the lifetime of the
413413
// buffer, but once this has been called Invalidate() cannot be used.
414414
// Content of the buffer in the range [0, length()) is preserved.
415-
void AllocateSufficientStorage(size_t storage) {
416-
CHECK(!IsInvalidated());
417-
if (storage > capacity()) {
418-
bool was_allocated = IsAllocated();
419-
T* allocated_ptr = was_allocated ? buf_ : nullptr;
420-
buf_ = Realloc(allocated_ptr, storage);
421-
capacity_ = storage;
422-
if (!was_allocated && length_ > 0)
423-
memcpy(buf_, buf_st_, length_ * sizeof(buf_[0]));
424-
}
425-
426-
length_ = storage;
427-
}
415+
void AllocateSufficientStorage(size_t storage);
428416

429417
void SetLength(size_t length) {
430418
// capacity() returns how much memory is actually available.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.