2022-02-02 14:55:12 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef GUniquePtr_h_
|
|
|
|
#define GUniquePtr_h_
|
|
|
|
|
|
|
|
// Provides GUniquePtr to g_free a given pointer.
|
|
|
|
|
|
|
|
#include <glib.h>
|
2022-04-26 03:36:32 +00:00
|
|
|
#include <gtk/gtk.h>
|
2022-02-02 14:55:12 +00:00
|
|
|
#include "mozilla/UniquePtr.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
struct GFreeDeleter {
|
|
|
|
constexpr GFreeDeleter() = default;
|
2022-09-06 13:48:12 +00:00
|
|
|
void operator()(GdkEventCrossing* aPtr) const {
|
|
|
|
gdk_event_free((GdkEvent*)aPtr);
|
|
|
|
}
|
2022-06-04 11:22:25 +00:00
|
|
|
void operator()(GdkEventKey* aPtr) const { gdk_event_free((GdkEvent*)aPtr); }
|
|
|
|
void operator()(GdkEvent* aPtr) const { gdk_event_free(aPtr); }
|
2022-02-10 12:19:59 +00:00
|
|
|
void operator()(GError* aPtr) const { g_error_free(aPtr); }
|
2022-02-02 14:55:12 +00:00
|
|
|
void operator()(void* aPtr) const { g_free(aPtr); }
|
2022-04-26 03:36:32 +00:00
|
|
|
void operator()(GtkPaperSize* aPtr) const { gtk_paper_size_free(aPtr); }
|
2024-02-15 12:52:12 +00:00
|
|
|
void operator()(gchar** aPtr) const { g_strfreev(aPtr); }
|
2022-02-02 14:55:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
using GUniquePtr = UniquePtr<T, GFreeDeleter>;
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|