mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 03:22:43 +00:00 
			
		
		
		
	Yet another pass of style fixes.
This commit is contained in:
		
							parent
							
								
									89040cdc99
								
							
						
					
					
						commit
						ec1c487dcd
					
				
					 43 changed files with 183 additions and 185 deletions
				
			
		|  | @ -46,25 +46,25 @@ public: | |||
| 
 | ||||
|     unsigned toUInt(bool& ok) const; | ||||
| 
 | ||||
|     String toLowercase() const | ||||
|     String to_lowercase() const | ||||
|     { | ||||
|         if (!m_impl) | ||||
|             return String(); | ||||
|         return m_impl->toLowercase(); | ||||
|         return m_impl->to_lowercase(); | ||||
|     } | ||||
| 
 | ||||
|     String toUppercase() const | ||||
|     String to_uppercase() const | ||||
|     { | ||||
|         if (!m_impl) | ||||
|             return String(); | ||||
|         return m_impl->toUppercase(); | ||||
|         return m_impl->to_uppercase(); | ||||
|     } | ||||
| 
 | ||||
|     Vector<String> split(char separator) const; | ||||
|     String substring(size_t start, size_t length) const; | ||||
| 
 | ||||
|     bool isNull() const { return !m_impl; } | ||||
|     bool isEmpty() const { return length() == 0; } | ||||
|     bool is_null() const { return !m_impl; } | ||||
|     bool is_empty() const { return length() == 0; } | ||||
|     unsigned length() const { return m_impl ? m_impl->length() : 0; } | ||||
|     const char* characters() const { return m_impl ? m_impl->characters() : nullptr; } | ||||
|     char operator[](unsigned i) const { ASSERT(m_impl); return (*m_impl)[i]; } | ||||
|  | @ -72,7 +72,7 @@ public: | |||
|     bool operator==(const String&) const; | ||||
|     bool operator!=(const String& other) const { return !(*this == other); } | ||||
| 
 | ||||
|     String isolatedCopy() const; | ||||
|     String isolated_copy() const; | ||||
| 
 | ||||
|     static String empty(); | ||||
| 
 | ||||
|  | @ -93,7 +93,7 @@ public: | |||
|         return *this; | ||||
|     } | ||||
| 
 | ||||
|     ByteBuffer toByteBuffer() const; | ||||
|     ByteBuffer to_byte_buffer() const; | ||||
| 
 | ||||
| private: | ||||
|     RetainPtr<StringImpl> m_impl; | ||||
|  |  | |||
							
								
								
									
										12
									
								
								AK/Buffer.h
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								AK/Buffer.h
									
										
									
									
									
								
							|  | @ -11,7 +11,7 @@ namespace AK { | |||
| template<typename T> | ||||
| class Buffer : public Retainable<Buffer<T>> { | ||||
| public: | ||||
|     static RetainPtr<Buffer> createUninitialized(size_t count); | ||||
|     static RetainPtr<Buffer> create_uninitialized(size_t count); | ||||
|     static RetainPtr<Buffer> copy(const T*, size_t count); | ||||
|     static RetainPtr<Buffer> wrap(T*, size_t count); | ||||
|     static RetainPtr<Buffer> adopt(T*, size_t count); | ||||
|  | @ -29,16 +29,16 @@ public: | |||
| 
 | ||||
|     T& operator[](size_t i) { ASSERT(i < m_size); return m_elements[i]; } | ||||
|     const T& operator[](size_t i) const { ASSERT(i < m_size); return m_elements[i]; } | ||||
|     bool isEmpty() const { return !m_size; } | ||||
|     bool is_empty() const { return !m_size; } | ||||
|     size_t size() const { return m_size; } | ||||
| 
 | ||||
|     T* pointer() { return m_elements; } | ||||
|     const T* pointer() const { return m_elements; } | ||||
| 
 | ||||
|     T* offsetPointer(size_t offset) { return m_elements + offset; } | ||||
|     const T* offsetPointer(size_t offset) const { return m_elements + offset; } | ||||
|     T* offset_pointer(size_t offset) { return m_elements + offset; } | ||||
|     const T* offset_pointer(size_t offset) const { return m_elements + offset; } | ||||
| 
 | ||||
|     const void* endPointer() const { return m_elements + m_size; } | ||||
|     const void* end_pointer() const { return m_elements + m_size; } | ||||
| 
 | ||||
|     // NOTE: trim() does not reallocate.
 | ||||
|     void trim(size_t size) | ||||
|  | @ -91,7 +91,7 @@ inline Buffer<T>::Buffer(T* elements, size_t size, ConstructionMode mode) | |||
| } | ||||
| 
 | ||||
| template<typename T> | ||||
| inline RetainPtr<Buffer<T>> Buffer<T>::createUninitialized(size_t size) | ||||
| inline RetainPtr<Buffer<T>> Buffer<T>::create_uninitialized(size_t size) | ||||
| { | ||||
|     return ::adopt(*new Buffer<T>(size)); | ||||
| } | ||||
|  |  | |||
|  | @ -30,8 +30,7 @@ public: | |||
|         return *this; | ||||
|     } | ||||
| 
 | ||||
|     static ByteBuffer createEmpty() { return ByteBuffer(Buffer<byte>::createUninitialized(0)); } | ||||
|     static ByteBuffer createUninitialized(size_t size) { return ByteBuffer(Buffer<byte>::createUninitialized(size)); } | ||||
|     static ByteBuffer create_uninitialized(size_t size) { return ByteBuffer(Buffer<byte>::create_uninitialized(size)); } | ||||
|     static ByteBuffer copy(const byte* data, size_t size) { return ByteBuffer(Buffer<byte>::copy(data, size)); } | ||||
|     static ByteBuffer wrap(byte* data, size_t size) { return ByteBuffer(Buffer<byte>::wrap(data, size)); } | ||||
|     static ByteBuffer adopt(byte* data, size_t size) { return ByteBuffer(Buffer<byte>::adopt(data, size)); } | ||||
|  | @ -39,22 +38,22 @@ public: | |||
|     ~ByteBuffer() { clear(); } | ||||
|     void clear() { m_impl = nullptr; } | ||||
| 
 | ||||
|     operator bool() const { return !isNull(); } | ||||
|     bool operator!() const { return isNull(); } | ||||
|     bool isNull() const { return m_impl == nullptr; } | ||||
|     operator bool() const { return !is_null(); } | ||||
|     bool operator!() const { return is_null(); } | ||||
|     bool is_null() const { return m_impl == nullptr; } | ||||
| 
 | ||||
|     byte& operator[](size_t i) { ASSERT(m_impl); return (*m_impl)[i]; } | ||||
|     byte operator[](size_t i) const { ASSERT(m_impl); return (*m_impl)[i]; } | ||||
|     bool isEmpty() const { return !m_impl || m_impl->isEmpty(); } | ||||
|     bool is_empty() const { return !m_impl || m_impl->is_empty(); } | ||||
|     size_t size() const { return m_impl ? m_impl->size() : 0; } | ||||
| 
 | ||||
|     byte* pointer() { return m_impl ? m_impl->pointer() : nullptr; } | ||||
|     const byte* pointer() const { return m_impl ? m_impl->pointer() : nullptr; } | ||||
| 
 | ||||
|     byte* offsetPointer(size_t offset) { return m_impl ? m_impl->offsetPointer(offset) : nullptr; } | ||||
|     const byte* offsetPointer(size_t offset) const { return m_impl ? m_impl->offsetPointer(offset) : nullptr; } | ||||
|     byte* offset_pointer(size_t offset) { return m_impl ? m_impl->offset_pointer(offset) : nullptr; } | ||||
|     const byte* offset_pointer(size_t offset) const { return m_impl ? m_impl->offset_pointer(offset) : nullptr; } | ||||
| 
 | ||||
|     const void* endPointer() const { return m_impl ? m_impl->endPointer() : nullptr; } | ||||
|     const void* end_pointer() const { return m_impl ? m_impl->end_pointer() : nullptr; } | ||||
| 
 | ||||
|     // NOTE: trim() does not reallocate.
 | ||||
|     void trim(size_t size) | ||||
|  | @ -65,13 +64,13 @@ public: | |||
| 
 | ||||
|     ByteBuffer slice(size_t offset, size_t size) const | ||||
|     { | ||||
|         if (isNull()) | ||||
|         if (is_null()) | ||||
|             return { }; | ||||
|         if (offset >= this->size()) | ||||
|             return { }; | ||||
|         if (offset + size >= this->size()) | ||||
|             size = this->size() - offset; | ||||
|         return copy(offsetPointer(offset), size); | ||||
|         return copy(offset_pointer(offset), size); | ||||
|     } | ||||
| 
 | ||||
| private: | ||||
|  |  | |||
|  | @ -19,7 +19,7 @@ public: | |||
|     DoublyLinkedList() { } | ||||
|     ~DoublyLinkedList() { clear(); } | ||||
| 
 | ||||
|     bool isEmpty() const { return !head(); } | ||||
|     bool is_empty() const { return !head(); } | ||||
| 
 | ||||
|     void clear() | ||||
|     { | ||||
|  |  | |||
|  | @ -22,14 +22,14 @@ bool FileSystemPath::canonicalize(bool resolve_symbolic_links) | |||
|         if (part == ".") | ||||
|             continue; | ||||
|         if (part == "..") { | ||||
|             if (!canonical_parts.isEmpty()) | ||||
|             if (!canonical_parts.is_empty()) | ||||
|                 canonical_parts.takeLast(); | ||||
|             continue; | ||||
|         } | ||||
|         if (!part.isEmpty()) | ||||
|         if (!part.is_empty()) | ||||
|             canonical_parts.append(part); | ||||
|     } | ||||
|     if (canonical_parts.isEmpty()) { | ||||
|     if (canonical_parts.is_empty()) { | ||||
|         m_string = m_basename = "/"; | ||||
|         return true; | ||||
|     } | ||||
|  |  | |||
|  | @ -46,7 +46,7 @@ public: | |||
|         return *this; | ||||
|     } | ||||
| 
 | ||||
|     bool isEmpty() const { return m_table.isEmpty(); } | ||||
|     bool is_empty() const { return m_table.is_empty(); } | ||||
|     unsigned size() const { return m_table.size(); } | ||||
|     unsigned capacity() const { return m_table.capacity(); } | ||||
|     void clear() { m_table.clear(); } | ||||
|  |  | |||
|  | @ -44,7 +44,7 @@ public: | |||
|     } | ||||
| 
 | ||||
|     ~HashTable() { clear(); } | ||||
|     bool isEmpty() const { return !m_size; } | ||||
|     bool is_empty() const { return !m_size; } | ||||
|     unsigned size() const { return m_size; } | ||||
|     unsigned capacity() const { return m_capacity; } | ||||
| 
 | ||||
|  | @ -112,7 +112,7 @@ public: | |||
|             , m_isEnd(isEnd) | ||||
|             , m_bucketIterator(bucketIterator) | ||||
|         { | ||||
|             if (!isEnd && !m_table.isEmpty() && !(m_bucketIterator != DoublyLinkedList<T>::Iterator::universalEnd())) { | ||||
|             if (!isEnd && !m_table.is_empty() && !(m_bucketIterator != DoublyLinkedList<T>::Iterator::universalEnd())) { | ||||
| #ifdef HASHTABLE_DEBUG | ||||
|                 kprintf("bucket iterator init!\n"); | ||||
| #endif | ||||
|  | @ -128,7 +128,7 @@ public: | |||
|         typename DoublyLinkedList<T>::Iterator m_bucketIterator; | ||||
|     }; | ||||
| 
 | ||||
|     Iterator begin() { return Iterator(*this, isEmpty()); } | ||||
|     Iterator begin() { return Iterator(*this, is_empty()); } | ||||
|     Iterator end() { return Iterator(*this, true); } | ||||
| 
 | ||||
|     class ConstIterator { | ||||
|  | @ -189,7 +189,7 @@ public: | |||
|             , m_isEnd(isEnd) | ||||
|             , m_bucketIterator(bucketIterator) | ||||
|         { | ||||
|             if (!isEnd && !m_table.isEmpty() && !(m_bucketIterator != DoublyLinkedList<T>::ConstIterator::universalEnd())) { | ||||
|             if (!isEnd && !m_table.is_empty() && !(m_bucketIterator != DoublyLinkedList<T>::ConstIterator::universalEnd())) { | ||||
| #ifdef HASHTABLE_DEBUG | ||||
|                 kprintf("const bucket iterator init!\n"); | ||||
| #endif | ||||
|  | @ -206,7 +206,7 @@ public: | |||
|         typename DoublyLinkedList<T>::ConstIterator m_bucketIterator; | ||||
|     }; | ||||
| 
 | ||||
|     ConstIterator begin() const { return ConstIterator(*this, isEmpty()); } | ||||
|     ConstIterator begin() const { return ConstIterator(*this, is_empty()); } | ||||
|     ConstIterator end() const { return ConstIterator(*this, true); } | ||||
| 
 | ||||
|     Iterator find(const T&); | ||||
|  | @ -323,7 +323,7 @@ void HashTable<T, TraitsForT>::insert(const T& value) | |||
| template<typename T, typename TraitsForT> | ||||
| bool HashTable<T, TraitsForT>::contains(const T& value) const | ||||
| { | ||||
|     if (isEmpty()) | ||||
|     if (is_empty()) | ||||
|         return false; | ||||
|     auto& bucket = lookup(value); | ||||
|     for (auto& e : bucket.chain) { | ||||
|  | @ -336,7 +336,7 @@ bool HashTable<T, TraitsForT>::contains(const T& value) const | |||
| template<typename T, typename TraitsForT> | ||||
| auto HashTable<T, TraitsForT>::find(const T& value) -> Iterator | ||||
| { | ||||
|     if (isEmpty()) | ||||
|     if (is_empty()) | ||||
|         return end(); | ||||
|     unsigned bucketIndex; | ||||
|     auto& bucket = lookup(value, &bucketIndex); | ||||
|  | @ -349,7 +349,7 @@ auto HashTable<T, TraitsForT>::find(const T& value) -> Iterator | |||
| template<typename T, typename TraitsForT> | ||||
| auto HashTable<T, TraitsForT>::find(const T& value) const -> ConstIterator | ||||
| { | ||||
|     if (isEmpty()) | ||||
|     if (is_empty()) | ||||
|         return end(); | ||||
|     unsigned bucketIndex; | ||||
|     auto& bucket = lookup(value, &bucketIndex); | ||||
|  | @ -362,7 +362,7 @@ auto HashTable<T, TraitsForT>::find(const T& value) const -> ConstIterator | |||
| template<typename T, typename TraitsForT> | ||||
| void HashTable<T, TraitsForT>::remove(Iterator it) | ||||
| { | ||||
|     ASSERT(!isEmpty()); | ||||
|     ASSERT(!is_empty()); | ||||
|     m_buckets[it.m_bucketIndex].chain.remove(it.m_bucketIterator); | ||||
|     --m_size; | ||||
| } | ||||
|  |  | |||
|  | @ -9,8 +9,8 @@ template<typename T> class InlineLinkedListNode { | |||
| public: | ||||
|     InlineLinkedListNode(); | ||||
|      | ||||
|     void setPrev(T*); | ||||
|     void setNext(T*); | ||||
|     void set_prev(T*); | ||||
|     void set_next(T*); | ||||
|      | ||||
|     T* prev() const; | ||||
|     T* next() const; | ||||
|  | @ -18,16 +18,16 @@ public: | |||
| 
 | ||||
| template<typename T> inline InlineLinkedListNode<T>::InlineLinkedListNode() | ||||
| { | ||||
|     setPrev(0); | ||||
|     setNext(0); | ||||
|     set_prev(0); | ||||
|     set_next(0); | ||||
| } | ||||
| 
 | ||||
| template<typename T> inline void InlineLinkedListNode<T>::setPrev(T* prev) | ||||
| template<typename T> inline void InlineLinkedListNode<T>::set_prev(T* prev) | ||||
| { | ||||
|     static_cast<T*>(this)->m_prev = prev; | ||||
| } | ||||
| 
 | ||||
| template<typename T> inline void InlineLinkedListNode<T>::setNext(T* next) | ||||
| template<typename T> inline void InlineLinkedListNode<T>::set_next(T* next) | ||||
| { | ||||
|     static_cast<T*>(this)->m_next = next; | ||||
| } | ||||
|  | @ -46,12 +46,12 @@ template<typename T> class InlineLinkedList { | |||
| public: | ||||
|     InlineLinkedList() { } | ||||
|      | ||||
|     bool isEmpty() const { return !m_head; } | ||||
|     size_t sizeSlow() const; | ||||
|     bool is_empty() const { return !m_head; } | ||||
|     size_t size_slow() const; | ||||
|     void clear(); | ||||
| 
 | ||||
|     T* head() const { return m_head; } | ||||
|     T* removeHead(); | ||||
|     T* remove_head(); | ||||
| 
 | ||||
|     T* tail() const { return m_tail; } | ||||
| 
 | ||||
|  | @ -60,7 +60,7 @@ public: | |||
|     void remove(T*); | ||||
|     void append(InlineLinkedList<T>&); | ||||
| 
 | ||||
|     bool containsSlow(T* value) const | ||||
|     bool contains_slow(T* value) const | ||||
|     { | ||||
|         for (T* node = m_head; node; node = node->next()) { | ||||
|             if (node == value) | ||||
|  | @ -74,7 +74,7 @@ private: | |||
|     T* m_tail { nullptr }; | ||||
| }; | ||||
| 
 | ||||
| template<typename T> inline size_t InlineLinkedList<T>::sizeSlow() const | ||||
| template<typename T> inline size_t InlineLinkedList<T>::size_slow() const | ||||
| { | ||||
|     size_t size = 0; | ||||
|     for (T* node = m_head; node; node = node->next()) | ||||
|  | @ -94,15 +94,15 @@ template<typename T> inline void InlineLinkedList<T>::prepend(T* node) | |||
|         ASSERT(!m_tail); | ||||
|         m_head = node; | ||||
|         m_tail = node; | ||||
|         node->setPrev(0); | ||||
|         node->setNext(0); | ||||
|         node->set_prev(0); | ||||
|         node->set_next(0); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     ASSERT(m_tail); | ||||
|     m_head->setPrev(node); | ||||
|     node->setNext(m_head); | ||||
|     node->setPrev(0); | ||||
|     m_head->set_prev(node); | ||||
|     node->set_next(m_head); | ||||
|     node->set_prev(0); | ||||
|     m_head = node; | ||||
| } | ||||
| 
 | ||||
|  | @ -112,15 +112,15 @@ template<typename T> inline void InlineLinkedList<T>::append(T* node) | |||
|         ASSERT(!m_head); | ||||
|         m_head = node; | ||||
|         m_tail = node; | ||||
|         node->setPrev(0); | ||||
|         node->setNext(0); | ||||
|         node->set_prev(0); | ||||
|         node->set_next(0); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     ASSERT(m_head); | ||||
|     m_tail->setNext(node); | ||||
|     node->setPrev(m_tail); | ||||
|     node->setNext(0); | ||||
|     m_tail->set_next(node); | ||||
|     node->set_prev(m_tail); | ||||
|     node->set_next(0); | ||||
|     m_tail = node; | ||||
| } | ||||
| 
 | ||||
|  | @ -128,7 +128,7 @@ template<typename T> inline void InlineLinkedList<T>::remove(T* node) | |||
| { | ||||
|     if (node->prev()) { | ||||
|         ASSERT(node != m_head); | ||||
|         node->prev()->setNext(node->next()); | ||||
|         node->prev()->set_next(node->next()); | ||||
|     } else { | ||||
|         ASSERT(node == m_head); | ||||
|         m_head = node->next(); | ||||
|  | @ -136,14 +136,14 @@ template<typename T> inline void InlineLinkedList<T>::remove(T* node) | |||
| 
 | ||||
|     if (node->next()) { | ||||
|         ASSERT(node != m_tail); | ||||
|         node->next()->setPrev(node->prev()); | ||||
|         node->next()->set_prev(node->prev()); | ||||
|     } else { | ||||
|         ASSERT(node == m_tail); | ||||
|         m_tail = node->prev(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| template<typename T> inline T* InlineLinkedList<T>::removeHead() | ||||
| template<typename T> inline T* InlineLinkedList<T>::remove_head() | ||||
| { | ||||
|     T* node = head(); | ||||
|     if (node) | ||||
|  | @ -165,19 +165,18 @@ template<typename T> inline void InlineLinkedList<T>::append(InlineLinkedList<T> | |||
| 
 | ||||
|     ASSERT(tail()); | ||||
|     ASSERT(other.head()); | ||||
|     T* otherHead = other.head(); | ||||
|     T* otherTail = other.tail(); | ||||
|     T* other_head = other.head(); | ||||
|     T* other_tail = other.tail(); | ||||
|     other.clear(); | ||||
| 
 | ||||
|     ASSERT(!m_tail->next()); | ||||
|     m_tail->setNext(otherHead); | ||||
|     ASSERT(!otherHead->prev()); | ||||
|     otherHead->setPrev(m_tail); | ||||
|     m_tail = otherTail; | ||||
|     m_tail->set_next(other_head); | ||||
|     ASSERT(!other_head->prev()); | ||||
|     other_head->set_prev(m_tail); | ||||
|     m_tail = other_tail; | ||||
| } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| using AK::InlineLinkedList; | ||||
| using AK::InlineLinkedListNode; | ||||
| 
 | ||||
|  |  | |||
|  | @ -17,7 +17,7 @@ public: | |||
|     SinglyLinkedList() { } | ||||
|     ~SinglyLinkedList() { clear(); } | ||||
| 
 | ||||
|     bool isEmpty() const { return !head(); } | ||||
|     bool is_empty() const { return !head(); } | ||||
| 
 | ||||
|     void clear() | ||||
|     { | ||||
|  |  | |||
|  | @ -19,17 +19,17 @@ bool String::operator==(const String& other) const | |||
| 
 | ||||
| String String::empty() | ||||
| { | ||||
|     return StringImpl::theEmptyStringImpl(); | ||||
|     return StringImpl::the_empty_stringimpl(); | ||||
| } | ||||
| 
 | ||||
| String String::isolatedCopy() const | ||||
| String String::isolated_copy() const | ||||
| { | ||||
|     if (!m_impl) | ||||
|         return { }; | ||||
|     if (!m_impl->length()) | ||||
|         return empty(); | ||||
|     char* buffer; | ||||
|     auto impl = StringImpl::createUninitialized(length(), buffer); | ||||
|     auto impl = StringImpl::create_uninitialized(length(), buffer); | ||||
|     memcpy(buffer, m_impl->characters(), m_impl->length()); | ||||
|     return String(move(*impl)); | ||||
| } | ||||
|  | @ -40,7 +40,7 @@ String String::substring(size_t start, size_t length) const | |||
|     ASSERT(start + length <= m_impl->length()); | ||||
|     // FIXME: This needs some input bounds checking.
 | ||||
|     char* buffer; | ||||
|     auto newImpl = StringImpl::createUninitialized(length, buffer); | ||||
|     auto newImpl = StringImpl::create_uninitialized(length, buffer); | ||||
|     memcpy(buffer, characters() + start, length); | ||||
|     buffer[length] = '\0'; | ||||
|     return newImpl; | ||||
|  | @ -48,7 +48,7 @@ String String::substring(size_t start, size_t length) const | |||
| 
 | ||||
| Vector<String> String::split(const char separator) const | ||||
| { | ||||
|     if (isEmpty()) | ||||
|     if (is_empty()) | ||||
|         return { }; | ||||
| 
 | ||||
|     Vector<String> v; | ||||
|  | @ -70,7 +70,7 @@ Vector<String> String::split(const char separator) const | |||
|     return v; | ||||
| } | ||||
| 
 | ||||
| ByteBuffer String::toByteBuffer() const | ||||
| ByteBuffer String::to_byte_buffer() const | ||||
| { | ||||
|     if (!m_impl) | ||||
|         return nullptr; | ||||
|  |  | |||
|  | @ -20,7 +20,7 @@ void StringBuilder::append(char ch) | |||
| String StringBuilder::build() | ||||
| { | ||||
|     auto strings = move(m_strings); | ||||
|     if (strings.isEmpty()) | ||||
|     if (strings.is_empty()) | ||||
|         return String::empty(); | ||||
| 
 | ||||
|     size_t sizeNeeded = 0; | ||||
|  | @ -28,7 +28,7 @@ String StringBuilder::build() | |||
|         sizeNeeded += string.length(); | ||||
| 
 | ||||
|     char* buffer; | ||||
|     auto impl = StringImpl::createUninitialized(sizeNeeded, buffer); | ||||
|     auto impl = StringImpl::create_uninitialized(sizeNeeded, buffer); | ||||
|     if (!impl) | ||||
|         return String(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -4,18 +4,18 @@ | |||
| 
 | ||||
| namespace AK { | ||||
| 
 | ||||
| static StringImpl* s_theEmptyStringImpl = nullptr; | ||||
| static StringImpl* s_the_empty_stringimpl = nullptr; | ||||
| 
 | ||||
| void StringImpl::initializeGlobals() | ||||
| void StringImpl::initialize_globals() | ||||
| { | ||||
|     s_theEmptyStringImpl = nullptr; | ||||
|     s_the_empty_stringimpl = nullptr; | ||||
| } | ||||
| 
 | ||||
| StringImpl& StringImpl::theEmptyStringImpl() | ||||
| StringImpl& StringImpl::the_empty_stringimpl() | ||||
| { | ||||
|     if (!s_theEmptyStringImpl) | ||||
|         s_theEmptyStringImpl = new StringImpl(ConstructTheEmptyStringImpl);; | ||||
|     return *s_theEmptyStringImpl; | ||||
|     if (!s_the_empty_stringimpl) | ||||
|         s_the_empty_stringimpl = new StringImpl(ConstructTheEmptyStringImpl);; | ||||
|     return *s_the_empty_stringimpl; | ||||
| } | ||||
| 
 | ||||
| StringImpl::~StringImpl() | ||||
|  | @ -27,7 +27,7 @@ static inline size_t allocationSizeForStringImpl(size_t length) | |||
|     return sizeof(StringImpl) + (sizeof(char) * length) + sizeof(char); | ||||
| } | ||||
| 
 | ||||
| RetainPtr<StringImpl> StringImpl::createUninitialized(size_t length, char*& buffer) | ||||
| RetainPtr<StringImpl> StringImpl::create_uninitialized(size_t length, char*& buffer) | ||||
| { | ||||
|     ASSERT(length); | ||||
|     void* slot = kmalloc(allocationSizeForStringImpl(length)); | ||||
|  | @ -46,10 +46,10 @@ RetainPtr<StringImpl> StringImpl::create(const char* cstring, size_t length, Sho | |||
|         return nullptr; | ||||
| 
 | ||||
|     if (!*cstring) | ||||
|         return theEmptyStringImpl(); | ||||
|         return the_empty_stringimpl(); | ||||
| 
 | ||||
|     char* buffer; | ||||
|     auto newStringImpl = createUninitialized(length, buffer); | ||||
|     auto newStringImpl = create_uninitialized(length, buffer); | ||||
|     if (!newStringImpl) | ||||
|         return nullptr; | ||||
|     memcpy(buffer, cstring, length * sizeof(char)); | ||||
|  | @ -94,7 +94,7 @@ static inline char toASCIIUppercase(char c) | |||
|     return c; | ||||
| } | ||||
| 
 | ||||
| RetainPtr<StringImpl> StringImpl::toLowercase() const | ||||
| RetainPtr<StringImpl> StringImpl::to_lowercase() const | ||||
| { | ||||
|     if (!m_length) | ||||
|         return const_cast<StringImpl*>(this); | ||||
|  | @ -107,7 +107,7 @@ RetainPtr<StringImpl> StringImpl::toLowercase() const | |||
| 
 | ||||
| slowPath: | ||||
|     char* buffer; | ||||
|     auto lowercased = createUninitialized(m_length, buffer); | ||||
|     auto lowercased = create_uninitialized(m_length, buffer); | ||||
|     if (!lowercased) | ||||
|         return nullptr; | ||||
|     for (size_t i = 0; i < m_length; ++i) | ||||
|  | @ -116,7 +116,7 @@ slowPath: | |||
|     return lowercased; | ||||
| } | ||||
| 
 | ||||
| RetainPtr<StringImpl> StringImpl::toUppercase() const | ||||
| RetainPtr<StringImpl> StringImpl::to_uppercase() const | ||||
| { | ||||
|     if (!m_length) | ||||
|         return const_cast<StringImpl*>(this); | ||||
|  | @ -129,7 +129,7 @@ RetainPtr<StringImpl> StringImpl::toUppercase() const | |||
| 
 | ||||
| slowPath: | ||||
|     char* buffer; | ||||
|     auto uppercased = createUninitialized(m_length, buffer); | ||||
|     auto uppercased = create_uninitialized(m_length, buffer); | ||||
|     if (!uppercased) | ||||
|         return nullptr; | ||||
|     for (size_t i = 0; i < m_length; ++i) | ||||
|  | @ -138,7 +138,7 @@ slowPath: | |||
|     return uppercased; | ||||
| } | ||||
| 
 | ||||
| void StringImpl::computeHash() const | ||||
| void StringImpl::compute_hash() const | ||||
| { | ||||
|     if (!length()) { | ||||
|         m_hash = 0; | ||||
|  |  | |||
|  | @ -10,14 +10,14 @@ enum ShouldChomp { NoChomp, Chomp }; | |||
| 
 | ||||
| class StringImpl : public Retainable<StringImpl> { | ||||
| public: | ||||
|     static RetainPtr<StringImpl> createUninitialized(size_t length, char*& buffer); | ||||
|     static RetainPtr<StringImpl> create_uninitialized(size_t length, char*& buffer); | ||||
|     static RetainPtr<StringImpl> create(const char* cstring, ShouldChomp = NoChomp); | ||||
|     static RetainPtr<StringImpl> create(const char* cstring, size_t length, ShouldChomp = NoChomp); | ||||
|     RetainPtr<StringImpl> toLowercase() const; | ||||
|     RetainPtr<StringImpl> toUppercase() const; | ||||
|     RetainPtr<StringImpl> to_lowercase() const; | ||||
|     RetainPtr<StringImpl> to_uppercase() const; | ||||
| 
 | ||||
|     static StringImpl& theEmptyStringImpl(); | ||||
|     static void initializeGlobals(); | ||||
|     static StringImpl& the_empty_stringimpl(); | ||||
|     static void initialize_globals(); | ||||
| 
 | ||||
|     ~StringImpl(); | ||||
| 
 | ||||
|  | @ -28,7 +28,7 @@ public: | |||
|     unsigned hash() const | ||||
|     { | ||||
|         if (!m_hasHash) | ||||
|             computeHash(); | ||||
|             compute_hash(); | ||||
|         return m_hash; | ||||
|     } | ||||
| 
 | ||||
|  | @ -37,15 +37,15 @@ private: | |||
|     explicit StringImpl(ConstructTheEmptyStringImplTag) : m_characters("") { } | ||||
| 
 | ||||
|     enum ConstructWithInlineBufferTag { ConstructWithInlineBuffer }; | ||||
|     explicit StringImpl(ConstructWithInlineBufferTag, size_t length) : m_length(length), m_characters(m_inlineBuffer) { } | ||||
|     explicit StringImpl(ConstructWithInlineBufferTag, size_t length) : m_length(length), m_characters(m_inline_buffer) { } | ||||
| 
 | ||||
|     void computeHash() const; | ||||
|     void compute_hash() const; | ||||
| 
 | ||||
|     size_t m_length { 0 }; | ||||
|     mutable bool m_hasHash { false }; | ||||
|     const char* m_characters { nullptr }; | ||||
|     mutable unsigned m_hash { 0 }; | ||||
|     char m_inlineBuffer[0]; | ||||
|     char m_inline_buffer[0]; | ||||
| }; | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -109,7 +109,7 @@ public: | |||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     bool isEmpty() const { return size() == 0; } | ||||
|     bool is_empty() const { return size() == 0; } | ||||
|     size_t size() const { return m_impl ? m_impl->size() : 0; } | ||||
|     size_t capacity() const { return m_impl ? m_impl->capacity() : 0; } | ||||
| 
 | ||||
|  | @ -130,7 +130,7 @@ public: | |||
| 
 | ||||
|     T takeLast() | ||||
|     { | ||||
|         ASSERT(!isEmpty()); | ||||
|         ASSERT(!is_empty()); | ||||
|         T value = move(last()); | ||||
|         last().~T(); | ||||
|         --m_impl->m_size; | ||||
|  |  | |||
|  | @ -29,7 +29,7 @@ public: | |||
|     T& operator*() { return *ptr(); } | ||||
|     const T& operator*() const { return *ptr(); } | ||||
| 
 | ||||
|     bool isNull() const { return !m_link || !m_link->ptr(); } | ||||
|     bool is_null() const { return !m_link || !m_link->ptr(); } | ||||
|     void clear() { m_link = nullptr; } | ||||
| 
 | ||||
|     WeakLink<T>* leakLink() { return m_link.leakRef(); } | ||||
|  |  | |||
							
								
								
									
										14
									
								
								AK/test.cpp
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								AK/test.cpp
									
										
									
									
									
								
							|  | @ -20,7 +20,7 @@ void log_unlocked() { } | |||
| 
 | ||||
| int main(int c, char** v) | ||||
| { | ||||
|     StringImpl::initializeGlobals(); | ||||
|     StringImpl::initialize_globals(); | ||||
| 
 | ||||
|     { | ||||
|         SpinLock lock; | ||||
|  | @ -32,7 +32,7 @@ int main(int c, char** v) | |||
|         if (c == 2) | ||||
|             testpath = v[1]; | ||||
|         FileSystemPath p(testpath); | ||||
|         if (p.string().isNull()) | ||||
|         if (p.string().is_null()) | ||||
|             printf("canonicalized path is null\n"); | ||||
|         else | ||||
|             printf("%s\n", p.string().characters()); | ||||
|  | @ -108,14 +108,14 @@ int main(int c, char** v) | |||
|     String empty = ""; | ||||
| 
 | ||||
|     char* buffer; | ||||
|     auto test = StringImpl::createUninitialized(3, buffer);  | ||||
|     auto test = StringImpl::create_uninitialized(3, buffer); | ||||
|     auto hello = String("hello"); | ||||
|     auto Hello = String("Hello"); | ||||
| 
 | ||||
|     printf("hello: '%s'\n", hello.characters()); | ||||
|     printf("Hello: '%s'\n", Hello.characters()); | ||||
|     printf("'Hello'.lower(): '%s'\n", Hello.toLowercase().characters()); | ||||
|     printf("'hello'.upper(): '%s'\n", Hello.toUppercase().characters()); | ||||
|     printf("'Hello'.lower(): '%s'\n", Hello.to_lowercase().characters()); | ||||
|     printf("'hello'.upper(): '%s'\n", Hello.to_uppercase().characters()); | ||||
| 
 | ||||
|     Vector<String> strings; | ||||
|     strings.append("a"); | ||||
|  | @ -188,7 +188,7 @@ int main(int c, char** v) | |||
|     list.append(3); | ||||
|     list.append(6); | ||||
|     list.append(9); | ||||
|     ASSERT(!list.isEmpty()); | ||||
|     ASSERT(!list.is_empty()); | ||||
|     ASSERT(list.first() == 3); | ||||
|     ASSERT(list.last() == 9); | ||||
| 
 | ||||
|  | @ -213,7 +213,7 @@ int main(int c, char** v) | |||
|         printf("not found\n"); | ||||
|     } | ||||
| 
 | ||||
|     auto charbuf = Buffer<char>::createUninitialized(1024); | ||||
|     auto charbuf = Buffer<char>::create_uninitialized(1024); | ||||
|     printf("charbuf.size() = %zu\n", charbuf->size()); | ||||
| 
 | ||||
|     { | ||||
|  |  | |||
|  | @ -16,7 +16,7 @@ ssize_t DoubleBuffer::write(const byte* data, size_t size) | |||
| 
 | ||||
| ssize_t DoubleBuffer::read(byte* data, size_t size) | ||||
| { | ||||
|     if (m_read_buffer_index >= m_read_buffer->size() && !m_write_buffer->isEmpty()) | ||||
|     if (m_read_buffer_index >= m_read_buffer->size() && !m_write_buffer->is_empty()) | ||||
|         flip(); | ||||
|     if (m_read_buffer_index >= m_read_buffer->size()) | ||||
|         return 0; | ||||
|  |  | |||
|  | @ -14,7 +14,7 @@ public: | |||
|     ssize_t write(const byte*, size_t); | ||||
|     ssize_t read(byte*, size_t); | ||||
| 
 | ||||
|     bool is_empty() const { return m_read_buffer_index >= m_read_buffer->size() && m_write_buffer->isEmpty(); } | ||||
|     bool is_empty() const { return m_read_buffer_index >= m_read_buffer->size() && m_write_buffer->is_empty(); } | ||||
| 
 | ||||
| private: | ||||
|     void flip(); | ||||
|  |  | |||
|  | @ -132,8 +132,8 @@ void IDEDiskDevice::initialize() | |||
|     enable_irq(); | ||||
|     wait_for_irq(); | ||||
| 
 | ||||
|     ByteBuffer wbuf = ByteBuffer::createUninitialized(512); | ||||
|     ByteBuffer bbuf = ByteBuffer::createUninitialized(512); | ||||
|     ByteBuffer wbuf = ByteBuffer::create_uninitialized(512); | ||||
|     ByteBuffer bbuf = ByteBuffer::create_uninitialized(512); | ||||
|     byte* b = bbuf.pointer(); | ||||
|     word* w = (word*)wbuf.pointer(); | ||||
|     const word* wbufbase = (word*)wbuf.pointer(); | ||||
|  |  | |||
|  | @ -32,7 +32,7 @@ ByteBuffer procfs$pid_fds(Process& process) | |||
| { | ||||
|     ProcessInspectionHandle handle(process); | ||||
|     char* buffer; | ||||
|     auto stringImpl = StringImpl::createUninitialized(process.number_of_open_file_descriptors() * 80, buffer); | ||||
|     auto stringImpl = StringImpl::create_uninitialized(process.number_of_open_file_descriptors() * 80, buffer); | ||||
|     memset(buffer, 0, stringImpl->length()); | ||||
|     char* ptr = buffer; | ||||
|     for (size_t i = 0; i < process.max_open_file_descriptors(); ++i) { | ||||
|  | @ -49,7 +49,7 @@ ByteBuffer procfs$pid_vm(Process& process) | |||
| { | ||||
|     ProcessInspectionHandle handle(process); | ||||
|     char* buffer; | ||||
|     auto stringImpl = StringImpl::createUninitialized(80 + process.regionCount() * 160 + 4096, buffer); | ||||
|     auto stringImpl = StringImpl::create_uninitialized(80 + process.regionCount() * 160 + 4096, buffer); | ||||
|     memset(buffer, 0, stringImpl->length()); | ||||
|     char* ptr = buffer; | ||||
|     ptr += ksprintf(ptr, "BEGIN       END         SIZE      COMMIT     NAME\n"); | ||||
|  | @ -69,7 +69,7 @@ ByteBuffer procfs$pid_vmo(Process& process) | |||
| { | ||||
|     ProcessInspectionHandle handle(process); | ||||
|     char* buffer; | ||||
|     auto stringImpl = StringImpl::createUninitialized(80 + process.regionCount() * 160 + 4096, buffer); | ||||
|     auto stringImpl = StringImpl::create_uninitialized(80 + process.regionCount() * 160 + 4096, buffer); | ||||
|     memset(buffer, 0, stringImpl->length()); | ||||
|     char* ptr = buffer; | ||||
|     ptr += ksprintf(ptr, "BEGIN       END         SIZE        NAME\n"); | ||||
|  | @ -118,7 +118,7 @@ ByteBuffer procfs$pid_stack(Process& process) | |||
|     for (auto& symbol : recognizedSymbols) { | ||||
|         bytesNeeded += symbol.ksym->name.length() + 8 + 16; | ||||
|     } | ||||
|     auto buffer = ByteBuffer::createUninitialized(bytesNeeded); | ||||
|     auto buffer = ByteBuffer::create_uninitialized(bytesNeeded); | ||||
|     char* bufptr = (char*)buffer.pointer(); | ||||
| 
 | ||||
|     for (auto& symbol : recognizedSymbols) { | ||||
|  | @ -134,7 +134,7 @@ ByteBuffer procfs$pid_regs(Process& process) | |||
| { | ||||
|     ProcessInspectionHandle handle(process); | ||||
|     auto& tss = process.tss(); | ||||
|     auto buffer = ByteBuffer::createUninitialized(1024); | ||||
|     auto buffer = ByteBuffer::create_uninitialized(1024); | ||||
|     char* ptr = (char*)buffer.pointer(); | ||||
|     ptr += ksprintf(ptr, "eax: %x\n", tss.eax); | ||||
|     ptr += ksprintf(ptr, "ebx: %x\n", tss.ebx); | ||||
|  | @ -156,7 +156,7 @@ ByteBuffer procfs$pid_exe(Process& process) | |||
|     ProcessInspectionHandle handle(process); | ||||
|     auto inode = process.executable_inode(); | ||||
|     ASSERT(inode); | ||||
|     return VFS::the().absolute_path(*inode).toByteBuffer(); | ||||
|     return VFS::the().absolute_path(*inode).to_byte_buffer(); | ||||
| } | ||||
| 
 | ||||
| ByteBuffer procfs$pid_cwd(Process& process) | ||||
|  | @ -164,7 +164,7 @@ ByteBuffer procfs$pid_cwd(Process& process) | |||
|     ProcessInspectionHandle handle(process); | ||||
|     auto inode = process.cwd_inode(); | ||||
|     ASSERT(inode); | ||||
|     return VFS::the().absolute_path(*inode).toByteBuffer(); | ||||
|     return VFS::the().absolute_path(*inode).to_byte_buffer(); | ||||
| } | ||||
| 
 | ||||
| void ProcFS::add_process(Process& process) | ||||
|  | @ -199,7 +199,7 @@ ByteBuffer procfs$mm() | |||
| { | ||||
|     // FIXME: Implement
 | ||||
|     InterruptDisabler disabler; | ||||
|     auto buffer = ByteBuffer::createUninitialized(1024 + 80 * MM.m_vmos.size()); | ||||
|     auto buffer = ByteBuffer::create_uninitialized(1024 + 80 * MM.m_vmos.size()); | ||||
|     char* ptr = (char*)buffer.pointer(); | ||||
|     for (auto* vmo : MM.m_vmos) { | ||||
|         ptr += ksprintf(ptr, "VMO: %p %s(%u): p:%4u %s\n", | ||||
|  | @ -219,7 +219,7 @@ ByteBuffer procfs$regions() | |||
| { | ||||
|     // FIXME: Implement
 | ||||
|     InterruptDisabler disabler; | ||||
|     auto buffer = ByteBuffer::createUninitialized(1024 + 80 * MM.m_regions.size()); | ||||
|     auto buffer = ByteBuffer::create_uninitialized(1024 + 80 * MM.m_regions.size()); | ||||
|     char* ptr = (char*)buffer.pointer(); | ||||
|     for (auto* region : MM.m_regions) { | ||||
|         ptr += ksprintf(ptr, "Region: %p VMO=%p %s\n", | ||||
|  | @ -235,7 +235,7 @@ ByteBuffer procfs$regions() | |||
| ByteBuffer procfs$mounts() | ||||
| { | ||||
|     InterruptDisabler disabler; | ||||
|     auto buffer = ByteBuffer::createUninitialized(VFS::the().mount_count() * 80); | ||||
|     auto buffer = ByteBuffer::create_uninitialized(VFS::the().mount_count() * 80); | ||||
|     char* ptr = (char*)buffer.pointer(); | ||||
|     VFS::the().for_each_mount([&ptr] (auto& mount) { | ||||
|         auto& fs = mount.guest_fs(); | ||||
|  | @ -251,7 +251,7 @@ ByteBuffer procfs$mounts() | |||
| 
 | ||||
| ByteBuffer procfs$cpuinfo() | ||||
| { | ||||
|     auto buffer = ByteBuffer::createUninitialized(256); | ||||
|     auto buffer = ByteBuffer::create_uninitialized(256); | ||||
|     char* ptr = (char*)buffer.pointer(); | ||||
|     { | ||||
|         CPUID cpuid(0); | ||||
|  | @ -316,7 +316,7 @@ ByteBuffer procfs$cpuinfo() | |||
| 
 | ||||
| ByteBuffer procfs$kmalloc() | ||||
| { | ||||
|     auto buffer = ByteBuffer::createUninitialized(256); | ||||
|     auto buffer = ByteBuffer::create_uninitialized(256); | ||||
|     char* ptr = (char*)buffer.pointer(); | ||||
|     ptr += ksprintf(ptr, "eternal:      %u\npage-aligned: %u\nallocated:    %u\nfree:         %u\n", kmalloc_sum_eternal, sum_alloc, sum_free); | ||||
|     buffer.trim(ptr - (char*)buffer.pointer()); | ||||
|  | @ -327,7 +327,7 @@ ByteBuffer procfs$summary() | |||
| { | ||||
|     InterruptDisabler disabler; | ||||
|     auto processes = Process::allProcesses(); | ||||
|     auto buffer = ByteBuffer::createUninitialized(processes.size() * 256); | ||||
|     auto buffer = ByteBuffer::create_uninitialized(processes.size() * 256); | ||||
|     char* ptr = (char*)buffer.pointer(); | ||||
|     ptr += ksprintf(ptr, "PID TPG PGP SID  OWNER  STATE      PPID NSCHED     FDS  TTY  NAME\n"); | ||||
|     for (auto* process : processes) { | ||||
|  | @ -352,7 +352,7 @@ ByteBuffer procfs$summary() | |||
| ByteBuffer procfs$vnodes() | ||||
| { | ||||
|     auto& vfs = VFS::the(); | ||||
|     auto buffer = ByteBuffer::createUninitialized(vfs.m_max_vnode_count * 256); | ||||
|     auto buffer = ByteBuffer::create_uninitialized(vfs.m_max_vnode_count * 256); | ||||
|     char* ptr = (char*)buffer.pointer(); | ||||
|     for (size_t i = 0; i < vfs.m_max_vnode_count; ++i) { | ||||
|         auto& vnode = vfs.m_nodes[i]; | ||||
|  | @ -362,7 +362,7 @@ ByteBuffer procfs$vnodes() | |||
|         String path; | ||||
|         if (vnode.core_inode()) | ||||
|             path = vfs.absolute_path(*vnode.core_inode()); | ||||
|         if (path.isEmpty()) { | ||||
|         if (path.is_empty()) { | ||||
|             if (auto* dev = vnode.characterDevice()) { | ||||
|                 if (dev->is_tty()) | ||||
|                     path = static_cast<const TTY*>(dev)->tty_name(); | ||||
|  |  | |||
|  | @ -39,7 +39,7 @@ static String& hostnameStorage(InterruptDisabler&) | |||
| static String getHostname() | ||||
| { | ||||
|     InterruptDisabler disabler; | ||||
|     return hostnameStorage(disabler).isolatedCopy(); | ||||
|     return hostnameStorage(disabler).isolated_copy(); | ||||
| } | ||||
| 
 | ||||
| CoolGlobals* g_cool_globals; | ||||
|  | @ -59,7 +59,7 @@ Vector<Process*> Process::allProcesses() | |||
| { | ||||
|     InterruptDisabler disabler; | ||||
|     Vector<Process*> processes; | ||||
|     processes.ensureCapacity(g_processes->sizeSlow()); | ||||
|     processes.ensureCapacity(g_processes->size_slow()); | ||||
|     for (auto* process = g_processes->head(); process; process = process->next()) | ||||
|         processes.append(process); | ||||
|     return processes; | ||||
|  | @ -278,7 +278,7 @@ pid_t Process::sys$fork(RegisterDump& regs) | |||
| int Process::do_exec(const String& path, Vector<String>&& arguments, Vector<String>&& environment) | ||||
| { | ||||
|     auto parts = path.split('/'); | ||||
|     if (parts.isEmpty()) | ||||
|     if (parts.is_empty()) | ||||
|         return -ENOENT; | ||||
| 
 | ||||
|     int error; | ||||
|  | @ -473,7 +473,7 @@ Process* Process::create_user_process(const String& path, uid_t uid, gid_t gid, | |||
| { | ||||
|     // FIXME: Don't split() the path twice (sys$spawn also does it...)
 | ||||
|     auto parts = path.split('/'); | ||||
|     if (arguments.isEmpty()) { | ||||
|     if (arguments.is_empty()) { | ||||
|         arguments.append(parts.last()); | ||||
|     } | ||||
|     RetainPtr<Vnode> cwd; | ||||
|  | @ -1239,7 +1239,7 @@ int Process::sys$getcwd(char* buffer, size_t size) | |||
|         return -EFAULT; | ||||
|     ASSERT(cwd_inode()); | ||||
|     auto path = VFS::the().absolute_path(*cwd_inode()); | ||||
|     if (path.isNull()) | ||||
|     if (path.is_null()) | ||||
|         return -EINVAL; | ||||
|     if (size < path.length() + 1) | ||||
|         return -ERANGE; | ||||
|  |  | |||
|  | @ -123,7 +123,7 @@ bool Scheduler::pick_next() | |||
|     auto* prevHead = g_processes->head(); | ||||
|     for (;;) { | ||||
|         // Move head to tail.
 | ||||
|         g_processes->append(g_processes->removeHead()); | ||||
|         g_processes->append(g_processes->remove_head()); | ||||
|         auto* process = g_processes->head(); | ||||
| 
 | ||||
|         if (process->state() == Process::Runnable || process->state() == Process::Running) { | ||||
|  |  | |||
|  | @ -28,7 +28,7 @@ static word s_gdtLength; | |||
| word gdt_alloc_entry() | ||||
| { | ||||
|     ASSERT(s_gdt_freelist); | ||||
|     ASSERT(!s_gdt_freelist->isEmpty()); | ||||
|     ASSERT(!s_gdt_freelist->is_empty()); | ||||
|     return s_gdt_freelist->takeLast(); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -87,7 +87,7 @@ static void loadKsyms(const ByteBuffer& buffer) | |||
| 
 | ||||
|     kprintf("Loading ksyms: \033[s"); | ||||
| 
 | ||||
|     while (bufptr < buffer.endPointer()) { | ||||
|     while (bufptr < buffer.end_pointer()) { | ||||
|         for (unsigned i = 0; i < 8; ++i) | ||||
|             address = (address << 4) | parseHexDigit(*(bufptr++)); | ||||
|         bufptr += 3; | ||||
|  | @ -276,7 +276,7 @@ void init() | |||
|     MemoryManager::initialize(); | ||||
| 
 | ||||
|     VFS::initialize_globals(); | ||||
|     StringImpl::initializeGlobals(); | ||||
|     StringImpl::initialize_globals(); | ||||
| 
 | ||||
|     PIT::initialize(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -18,7 +18,7 @@ extern "C" int _start() | |||
|     __stdio_init(); | ||||
|     __malloc_init(); | ||||
| 
 | ||||
|     StringImpl::initializeGlobals(); | ||||
|     StringImpl::initialize_globals(); | ||||
| 
 | ||||
|     int status = 254; | ||||
|     int argc; | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ | |||
| 
 | ||||
| static unsigned parseUInt(const String& str, bool& ok) | ||||
| { | ||||
|     if (str.isEmpty()) { | ||||
|     if (str.is_empty()) { | ||||
|         ok = false; | ||||
|         return 0; | ||||
|     } | ||||
|  |  | |||
|  | @ -55,7 +55,7 @@ ByteBuffer DiskBackedFS::readBlock(unsigned index) const | |||
|     } | ||||
| #endif | ||||
| 
 | ||||
|     auto buffer = ByteBuffer::createUninitialized(blockSize()); | ||||
|     auto buffer = ByteBuffer::create_uninitialized(blockSize()); | ||||
|     //kprintf("created block buffer with size %u\n", blockSize());
 | ||||
|     DiskOffset baseOffset = static_cast<DiskOffset>(index) * static_cast<DiskOffset>(blockSize()); | ||||
|     auto* bufferPointer = buffer.pointer(); | ||||
|  | @ -81,7 +81,7 @@ ByteBuffer DiskBackedFS::readBlocks(unsigned index, unsigned count) const | |||
|         return nullptr; | ||||
|     if (count == 1) | ||||
|         return readBlock(index); | ||||
|     auto blocks = ByteBuffer::createUninitialized(count * blockSize()); | ||||
|     auto blocks = ByteBuffer::create_uninitialized(count * blockSize()); | ||||
|     byte* out = blocks.pointer(); | ||||
| 
 | ||||
|     for (unsigned i = 0; i < count; ++i) { | ||||
|  |  | |||
|  | @ -27,9 +27,9 @@ Ext2FS::~Ext2FS() | |||
| 
 | ||||
| ByteBuffer Ext2FS::read_super_block() const | ||||
| { | ||||
|     auto buffer = ByteBuffer::createUninitialized(1024); | ||||
|     auto buffer = ByteBuffer::create_uninitialized(1024); | ||||
|     device().read_block(2, buffer.pointer()); | ||||
|     device().read_block(3, buffer.offsetPointer(512)); | ||||
|     device().read_block(3, buffer.offset_pointer(512)); | ||||
|     return buffer; | ||||
| } | ||||
| 
 | ||||
|  | @ -172,7 +172,7 @@ OwnPtr<ext2_inode> Ext2FS::lookup_ext2_inode(unsigned inode) const | |||
|         return { }; | ||||
| 
 | ||||
|     auto* e2inode = reinterpret_cast<ext2_inode*>(kmalloc(inode_size())); | ||||
|     memcpy(e2inode, reinterpret_cast<ext2_inode*>(block.offsetPointer(offset)), inode_size()); | ||||
|     memcpy(e2inode, reinterpret_cast<ext2_inode*>(block.offset_pointer(offset)), inode_size()); | ||||
| #ifdef EXT2_DEBUG | ||||
|     dumpExt2Inode(*e2inode); | ||||
| #endif | ||||
|  | @ -357,14 +357,14 @@ ssize_t Ext2FSInode::read_bytes(Unix::off_t offset, size_t count, byte* buffer, | |||
|         return nread; | ||||
|     } | ||||
| 
 | ||||
|     if (m_block_list.isEmpty()) { | ||||
|     if (m_block_list.is_empty()) { | ||||
|         auto block_list = fs().block_list_for_inode(m_raw_inode); | ||||
|         LOCKER(m_lock); | ||||
|         if (m_block_list.size() != block_list.size()) | ||||
|             m_block_list = move(block_list); | ||||
|     } | ||||
| 
 | ||||
|     if (m_block_list.isEmpty()) { | ||||
|     if (m_block_list.is_empty()) { | ||||
|         kprintf("ext2fs: read_bytes: empty block list for inode %u\n", index()); | ||||
|         return -EIO; | ||||
|     } | ||||
|  | @ -436,7 +436,7 @@ ssize_t Ext2FS::read_inode_bytes(InodeIdentifier inode, Unix::off_t offset, size | |||
|     // FIXME: It's grossly inefficient to fetch the blocklist on every call to readInodeBytes().
 | ||||
|     //        It needs to be cached!
 | ||||
|     auto list = block_list_for_inode(*e2inode); | ||||
|     if (list.isEmpty()) { | ||||
|     if (list.is_empty()) { | ||||
|         kprintf("ext2fs: readInodeBytes: empty block list for inode %u\n", inode.index()); | ||||
|         return -EIO; | ||||
|     } | ||||
|  | @ -500,7 +500,7 @@ bool Ext2FS::write_inode(InodeIdentifier inode, const ByteBuffer& data) | |||
|     ASSERT(blocksNeededBefore == blocksNeededAfter); | ||||
| 
 | ||||
|     auto list = block_list_for_inode(*e2inode); | ||||
|     if (list.isEmpty()) { | ||||
|     if (list.is_empty()) { | ||||
|         kprintf("ext2fs: writeInode: empty block list for inode %u\n", inode.index()); | ||||
|         return false; | ||||
|     } | ||||
|  | @ -527,7 +527,7 @@ bool Ext2FSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntry&) | |||
|     ASSERT(buffer); | ||||
|     auto* entry = reinterpret_cast<ext2_dir_entry_2*>(buffer.pointer()); | ||||
| 
 | ||||
|     while (entry < buffer.endPointer()) { | ||||
|     while (entry < buffer.end_pointer()) { | ||||
|         if (entry->inode != 0) { | ||||
| #ifdef EXT2_DEBUG | ||||
|             kprintf("Ext2Inode::traverse_as_directory: %u, name_len: %u, rec_len: %u, file_type: %u, name: %s\n", entry->inode, entry->name_len, entry->rec_len, entry->file_type, namebuf); | ||||
|  | @ -586,7 +586,7 @@ bool Ext2FS::write_directory_inode(unsigned directoryInode, Vector<DirectoryEntr | |||
| 
 | ||||
|     dbgprintf("Ext2FS: directory size: %u (occupied: %u)\n", directorySize, occupiedSize); | ||||
| 
 | ||||
|     auto directoryData = ByteBuffer::createUninitialized(occupiedSize); | ||||
|     auto directoryData = ByteBuffer::create_uninitialized(occupiedSize); | ||||
| 
 | ||||
|     BufferStream stream(directoryData); | ||||
|     for (unsigned i = 0; i < entries.size(); ++i) { | ||||
|  | @ -752,7 +752,7 @@ bool Ext2FS::write_ext2_inode(unsigned inode, const ext2_inode& e2inode) | |||
|                 cached_inode.m_lookup_cache.clear(); | ||||
|         } | ||||
|     } | ||||
|     memcpy(reinterpret_cast<ext2_inode*>(block.offsetPointer(offset)), &e2inode, inode_size()); | ||||
|     memcpy(reinterpret_cast<ext2_inode*>(block.offset_pointer(offset)), &e2inode, inode_size()); | ||||
|     writeBlock(blockIndex, block); | ||||
|     return true; | ||||
| } | ||||
|  | @ -1000,7 +1000,7 @@ InodeIdentifier Ext2FS::create_inode(InodeIdentifier parentInode, const String& | |||
|     } | ||||
| 
 | ||||
|     auto blocks = allocate_blocks(group_index_from_inode(inode), ceilDiv(size, blockSize())); | ||||
|     if (blocks.isEmpty()) { | ||||
|     if (blocks.is_empty()) { | ||||
|         kprintf("Ext2FS: createInode: allocateBlocks failed\n"); | ||||
|         error = -ENOSPC; | ||||
|         return { }; | ||||
|  | @ -1091,7 +1091,7 @@ InodeIdentifier Ext2FS::find_parent_of_inode(InodeIdentifier inode_id) const | |||
| 
 | ||||
|     InodeIdentifier foundParent; | ||||
|     for (auto& directory : directories_in_group) { | ||||
|         if (!directory->reverse_lookup(inode->identifier()).isNull()) { | ||||
|         if (!directory->reverse_lookup(inode->identifier()).is_null()) { | ||||
|             foundParent = directory->identifier(); | ||||
|             break; | ||||
|         } | ||||
|  | @ -1104,7 +1104,7 @@ void Ext2FSInode::populate_lookup_cache() | |||
| { | ||||
|     { | ||||
|         LOCKER(m_lock); | ||||
|         if (!m_lookup_cache.isEmpty()) | ||||
|         if (!m_lookup_cache.is_empty()) | ||||
|             return; | ||||
|     } | ||||
|     HashMap<String, unsigned> children; | ||||
|  | @ -1115,7 +1115,7 @@ void Ext2FSInode::populate_lookup_cache() | |||
|     }); | ||||
| 
 | ||||
|     LOCKER(m_lock); | ||||
|     if (!m_lookup_cache.isEmpty()) | ||||
|     if (!m_lookup_cache.is_empty()) | ||||
|         return; | ||||
|     m_lookup_cache = move(children); | ||||
| } | ||||
|  |  | |||
|  | @ -188,7 +188,7 @@ ByteBuffer FileDescriptor::read_entire_file() | |||
|     ASSERT(!is_fifo()); | ||||
| 
 | ||||
|     if (m_vnode->isCharacterDevice()) { | ||||
|         auto buffer = ByteBuffer::createUninitialized(1024); | ||||
|         auto buffer = ByteBuffer::create_uninitialized(1024); | ||||
|         ssize_t nread = m_vnode->characterDevice()->read(buffer.pointer(), buffer.size()); | ||||
|         buffer.trim(nread); | ||||
|         return buffer; | ||||
|  | @ -214,7 +214,7 @@ ssize_t FileDescriptor::get_dir_entries(byte* buffer, size_t size) | |||
|         return -ENOTDIR; | ||||
| 
 | ||||
|     // FIXME: Compute the actual size needed.
 | ||||
|     auto tempBuffer = ByteBuffer::createUninitialized(2048); | ||||
|     auto tempBuffer = ByteBuffer::create_uninitialized(2048); | ||||
|     BufferStream stream(tempBuffer); | ||||
|     m_vnode->vfs()->traverse_directory_inode(*m_vnode->core_inode(), [&stream] (auto& entry) { | ||||
|         stream << (dword)entry.inode.index(); | ||||
|  |  | |||
|  | @ -21,7 +21,7 @@ static HashTable<Inode*>& all_inodes() | |||
|     return *s_inode_set; | ||||
| } | ||||
| 
 | ||||
| void FS::initializeGlobals() | ||||
| void FS::initialize_globals() | ||||
| { | ||||
|     s_lastFileSystemID = 0; | ||||
|     s_fs_map = nullptr; | ||||
|  | @ -52,7 +52,7 @@ ByteBuffer Inode::read_entire(FileDescriptor* descriptor) | |||
|     return fs().read_entire_inode(identifier(), descriptor); | ||||
| /*
 | ||||
|     size_t initial_size = metadata().size ? metadata().size : 4096; | ||||
|     auto contents = ByteBuffer::createUninitialized(initial_size); | ||||
|     auto contents = ByteBuffer::create_uninitialized(initial_size); | ||||
| 
 | ||||
|     ssize_t nread; | ||||
|     byte buffer[4096]; | ||||
|  | @ -90,7 +90,7 @@ ByteBuffer FS::read_entire_inode(InodeIdentifier inode, FileDescriptor* handle) | |||
|     } | ||||
| 
 | ||||
|     size_t initialSize = metadata.size ? metadata.size : 4096; | ||||
|     auto contents = ByteBuffer::createUninitialized(initialSize); | ||||
|     auto contents = ByteBuffer::create_uninitialized(initialSize); | ||||
| 
 | ||||
|     ssize_t nread; | ||||
|     byte buffer[4096]; | ||||
|  |  | |||
|  | @ -21,7 +21,7 @@ class FileDescriptor; | |||
| 
 | ||||
| class FS : public Retainable<FS> { | ||||
| public: | ||||
|     static void initializeGlobals(); | ||||
|     static void initialize_globals(); | ||||
|     virtual ~FS(); | ||||
| 
 | ||||
|     dword id() const { return m_fsid; } | ||||
|  |  | |||
|  | @ -22,7 +22,7 @@ VFS& VFS::the() | |||
| void VFS::initialize_globals() | ||||
| { | ||||
|     s_the = nullptr; | ||||
|     FS::initializeGlobals(); | ||||
|     FS::initialize_globals(); | ||||
| } | ||||
| 
 | ||||
| VFS::VFS() | ||||
|  | @ -177,7 +177,7 @@ bool VFS::mount_root(RetainPtr<FS>&& fileSystem) | |||
| 
 | ||||
| auto VFS::allocateNode() -> RetainPtr<Vnode> | ||||
| { | ||||
|     if (m_vnode_freelist.isEmpty()) { | ||||
|     if (m_vnode_freelist.is_empty()) { | ||||
|         kprintf("VFS: allocateNode has no nodes left\n"); | ||||
|         return nullptr; | ||||
|     } | ||||
|  | @ -351,7 +351,7 @@ String VFS::absolute_path(Inode& core_inode) | |||
|         ASSERT(parent_id.is_valid()); | ||||
|         inode = get_inode(parent_id); | ||||
|     } | ||||
|     if (lineage.isEmpty()) | ||||
|     if (lineage.is_empty()) | ||||
|         return "/"; | ||||
|     lineage.append(m_root_vnode->inode); | ||||
|     StringBuilder builder; | ||||
|  | @ -369,7 +369,7 @@ String VFS::absolute_path(Inode& core_inode) | |||
| 
 | ||||
| InodeIdentifier VFS::resolve_path(const String& path, InodeIdentifier base, int& error, int options, InodeIdentifier* deepest_dir) | ||||
| { | ||||
|     if (path.isEmpty()) { | ||||
|     if (path.is_empty()) { | ||||
|         error = -EINVAL; | ||||
|         return { }; | ||||
|     } | ||||
|  | @ -388,7 +388,7 @@ InodeIdentifier VFS::resolve_path(const String& path, InodeIdentifier base, int& | |||
|     for (unsigned i = 0; i < parts.size(); ++i) { | ||||
|         bool inode_was_root_at_head_of_loop = crumb_id.is_root_inode(); | ||||
|         auto& part = parts[i]; | ||||
|         if (part.isEmpty()) | ||||
|         if (part.is_empty()) | ||||
|             break; | ||||
|         auto metadata = crumb_id.metadata(); | ||||
|         if (!metadata.isValid()) { | ||||
|  |  | |||
|  | @ -109,7 +109,7 @@ int main(int c, char** v) | |||
|         String command = cmdbuf; | ||||
|         auto parts = command.split(' '); | ||||
| 
 | ||||
|         if (parts.isEmpty()) | ||||
|         if (parts.is_empty()) | ||||
|             continue; | ||||
| 
 | ||||
|         String cmd = parts[0]; | ||||
|  |  | |||
|  | @ -61,7 +61,7 @@ void Button::paintEvent(PaintEvent&) | |||
|         painter.drawLine({ 2, height() - 3 }, { width() - 2, height() - 3 }, shadowColor); | ||||
|     } | ||||
| 
 | ||||
|     if (!caption().isEmpty()) { | ||||
|     if (!caption().is_empty()) { | ||||
|         auto textRect = rect(); | ||||
|         if (m_beingPressed) | ||||
|             textRect.moveBy(1, 1); | ||||
|  |  | |||
|  | @ -89,7 +89,7 @@ void CheckBox::paintEvent(PaintEvent&) | |||
|     painter.fillRect(rect(), backgroundColor()); | ||||
|     painter.drawBitmap(bitmapPosition, *bitmap, foregroundColor()); | ||||
| 
 | ||||
|     if (!caption().isEmpty()) { | ||||
|     if (!caption().is_empty()) { | ||||
|         painter.drawText(textRect, caption(), Painter::TextAlignment::TopLeft, foregroundColor()); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -23,7 +23,7 @@ EventLoop& EventLoop::main() | |||
| int EventLoop::exec() | ||||
| { | ||||
|     for (;;) { | ||||
|         if (m_queuedEvents.isEmpty()) | ||||
|         if (m_queuedEvents.is_empty()) | ||||
|             waitForEvent(); | ||||
|         auto events = std::move(m_queuedEvents); | ||||
|         for (auto& queuedEvent : events) { | ||||
|  |  | |||
|  | @ -23,7 +23,7 @@ void Label::paintEvent(PaintEvent&) | |||
| { | ||||
|     Painter painter(*this); | ||||
|     painter.fillRect({ 0, 0, width(), height() }, backgroundColor()); | ||||
|     if (!text().isEmpty()) | ||||
|     if (!text().is_empty()) | ||||
|         painter.drawText({ 4, 4, width(), height() }, text(), Painter::TextAlignment::TopLeft, foregroundColor()); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -12,7 +12,7 @@ public: | |||
|     { | ||||
|     } | ||||
| 
 | ||||
|     bool isEmpty() const | ||||
|     bool is_empty() const | ||||
|     { | ||||
|         return width() == 0 || height() == 0; | ||||
|     } | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ public: | |||
|     Size() { } | ||||
|     Size(int w, int h) : m_width(w), m_height(h) { } | ||||
| 
 | ||||
|     bool isEmpty() const { return !m_width || !m_height; } | ||||
|     bool is_empty() const { return !m_width || !m_height; } | ||||
| 
 | ||||
|     int width() const { return m_width; } | ||||
|     int height() const { return m_height; } | ||||
|  |  | |||
|  | @ -148,7 +148,7 @@ void TerminalWidget::onReceive(byte ch) | |||
| 
 | ||||
| void TerminalWidget::keyDownEvent(KeyEvent& event) | ||||
| { | ||||
|     if (event.text().isEmpty()) | ||||
|     if (event.text().is_empty()) | ||||
|         return; | ||||
|     write(g_fd, event.text().characters(), event.text().length()); | ||||
| } | ||||
|  |  | |||
|  | @ -78,7 +78,7 @@ void TextBox::handleBackspace() | |||
|     } | ||||
| 
 | ||||
|     char* buffer; | ||||
|     auto newText = StringImpl::createUninitialized(m_text.length() - 1, buffer); | ||||
|     auto newText = StringImpl::create_uninitialized(m_text.length() - 1, buffer); | ||||
| 
 | ||||
|     memcpy(buffer, m_text.characters(), m_cursorPosition - 1); | ||||
|     memcpy(buffer + m_cursorPosition - 1, m_text.characters() + m_cursorPosition, m_text.length() - (m_cursorPosition - 1)); | ||||
|  | @ -111,11 +111,11 @@ void TextBox::keyDownEvent(KeyEvent& event) | |||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     if (!event.text().isEmpty()) { | ||||
|     if (!event.text().is_empty()) { | ||||
|         ASSERT(event.text().length() == 1); | ||||
| 
 | ||||
|         char* buffer; | ||||
|         auto newText = StringImpl::createUninitialized(m_text.length() + 1, buffer); | ||||
|         auto newText = StringImpl::create_uninitialized(m_text.length() + 1, buffer); | ||||
| 
 | ||||
|         memcpy(buffer, m_text.characters(), m_cursorPosition); | ||||
|         buffer[m_cursorPosition] = event.text()[0]; | ||||
|  |  | |||
|  | @ -78,7 +78,7 @@ void Window::event(Event& event) | |||
|             return; | ||||
|         } | ||||
|         if (m_mainWidget) { | ||||
|             if (pe.rect().isEmpty()) | ||||
|             if (pe.rect().is_empty()) | ||||
|                 return m_mainWidget->event(*make<PaintEvent>(m_mainWidget->rect())); | ||||
|             else | ||||
|                 return m_mainWidget->event(event); | ||||
|  |  | |||
|  | @ -94,7 +94,7 @@ void WindowManager::paintWindowFrame(Window& window) | |||
|     }; | ||||
| 
 | ||||
| 
 | ||||
|     if (!m_lastDragRect.isEmpty()) { | ||||
|     if (!m_lastDragRect.is_empty()) { | ||||
|         p.xorRect(m_lastDragRect, Color::Red); | ||||
|         m_lastDragRect = Rect(); | ||||
|     } | ||||
|  | @ -137,7 +137,7 @@ void WindowManager::removeWindow(Window& window) | |||
|         return; | ||||
| 
 | ||||
|     m_windows.remove(&window); | ||||
|     if (!activeWindow() && !m_windows.isEmpty()) | ||||
|     if (!activeWindow() && !m_windows.is_empty()) | ||||
|         setActiveWindow(*m_windows.begin()); | ||||
| 
 | ||||
|     repaint(); | ||||
|  | @ -245,7 +245,7 @@ void WindowManager::processMouseEvent(MouseEvent& event) | |||
| void WindowManager::handlePaintEvent(PaintEvent& event) | ||||
| { | ||||
|     //printf("[WM] paint event\n");
 | ||||
|     if (event.rect().isEmpty()) { | ||||
|     if (event.rect().is_empty()) { | ||||
|         event.m_rect.setWidth(AbstractScreen::the().width()); | ||||
|         event.m_rect.setHeight(AbstractScreen::the().height()); | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling