1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:07:35 +00:00

AK: Rename adopt() to adopt_ref()

This makes it more symmetrical with adopt_own() (which is used to
create a NonnullOwnPtr from the result of a naked new.)
This commit is contained in:
Andreas Kling 2021-04-23 16:46:57 +02:00
parent b3db01e20e
commit b91c49364d
228 changed files with 461 additions and 461 deletions

View file

@ -61,7 +61,7 @@ RefPtr<AnonymousBufferImpl> AnonymousBufferImpl::create(int fd, size_t size)
perror("mmap");
return {};
}
return adopt(*new AnonymousBufferImpl(fd, size, data));
return adopt_ref(*new AnonymousBufferImpl(fd, size, data));
}
AnonymousBufferImpl::~AnonymousBufferImpl()

View file

@ -20,25 +20,25 @@ NonnullRefPtr<ConfigFile> ConfigFile::get_for_lib(const String& lib_name)
String directory = StandardPaths::config_directory();
auto path = String::formatted("{}/lib/{}.ini", directory, lib_name);
return adopt(*new ConfigFile(path));
return adopt_ref(*new ConfigFile(path));
}
NonnullRefPtr<ConfigFile> ConfigFile::get_for_app(const String& app_name)
{
String directory = StandardPaths::config_directory();
auto path = String::formatted("{}/{}.ini", directory, app_name);
return adopt(*new ConfigFile(path));
return adopt_ref(*new ConfigFile(path));
}
NonnullRefPtr<ConfigFile> ConfigFile::get_for_system(const String& app_name)
{
auto path = String::formatted("/etc/{}.ini", app_name);
return adopt(*new ConfigFile(path));
return adopt_ref(*new ConfigFile(path));
}
NonnullRefPtr<ConfigFile> ConfigFile::open(const String& path)
{
return adopt(*new ConfigFile(path));
return adopt_ref(*new ConfigFile(path));
}
ConfigFile::ConfigFile(const String& file_name)

View file

@ -525,7 +525,7 @@ int EventLoop::register_signal(int signo, Function<void(int)> handler)
auto& info = *signals_info();
auto handlers = info.signal_handlers.find(signo);
if (handlers == info.signal_handlers.end()) {
auto signal_handlers = adopt(*new SignalHandlers(signo, EventLoop::handle_signal));
auto signal_handlers = adopt_ref(*new SignalHandlers(signo, EventLoop::handle_signal));
auto handler_id = signal_handlers->add(move(handler));
info.signal_handlers.set(signo, move(signal_handlers));
return handler_id;

View file

@ -103,7 +103,7 @@ Result<NonnullRefPtr<FileWatcher>, String> FileWatcher::watch(const String& path
dbgln_if(FILE_WATCHER_DEBUG, "Started watcher for file '{}'", path.characters());
auto notifier = Notifier::construct(watch_fd, Notifier::Event::Read);
return adopt(*new FileWatcher(move(notifier), move(path)));
return adopt_ref(*new FileWatcher(move(notifier), move(path)));
}
FileWatcher::FileWatcher(NonnullRefPtr<Notifier> notifier, const String& path)

View file

@ -32,7 +32,7 @@ public: \
template<class... Args> \
static inline NonnullRefPtr<klass> construct(Args&&... args) \
{ \
return adopt(*new klass(forward<Args>(args)...)); \
return adopt_ref(*new klass(forward<Args>(args)...)); \
}
#define C_OBJECT_ABSTRACT(klass) \

View file

@ -17,13 +17,13 @@ class Timer final : public Object {
public:
static NonnullRefPtr<Timer> create_repeating(int interval, Function<void()>&& timeout_handler, Object* parent = nullptr)
{
auto timer = adopt(*new Timer(interval, move(timeout_handler), parent));
auto timer = adopt_ref(*new Timer(interval, move(timeout_handler), parent));
timer->stop();
return timer;
}
static NonnullRefPtr<Timer> create_single_shot(int interval, Function<void()>&& timeout_handler, Object* parent = nullptr)
{
auto timer = adopt(*new Timer(interval, move(timeout_handler), parent));
auto timer = adopt_ref(*new Timer(interval, move(timeout_handler), parent));
timer->set_single_shot(true);
timer->stop();
return timer;