Remove PurpleMemoryPool as it is no longer used
Testing Done:
Compiled
Reviewed at https://reviews.imfreedom.org/r/1759/
--- a/libpurple/memorypool.c Mon Sep 12 22:40:17 2022 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,362 +0,0 @@
- * Purple is the legal property of its developers, whose names are too
- * numerous to list here. Please refer to the COPYRIGHT file distributed
- * with this source distribution
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
-#define PURPLE_MEMORY_POOL_BLOCK_PADDING (sizeof(guint64))
-#define PURPLE_MEMORY_POINTER_SHIFT(pointer, value) \
- (gpointer)((guintptr)(pointer) + (value))
-#define PURPLE_MEMORY_PADDED(pointer, padding) \
- (gpointer)((((guintptr)(pointer) - 1) / (padding) + 1) * padding)
-#define PURPLE_MEMORY_POOL_DEFAULT_BLOCK_SIZE 1024
-#define PURPLE_MEMORY_POOL_DISABLED FALSE
-typedef struct _PurpleMemoryPoolBlock PurpleMemoryPoolBlock;
- PurpleMemoryPoolBlock *first_block;
- PurpleMemoryPoolBlock *last_block;
-} PurpleMemoryPoolPrivate;
-struct _PurpleMemoryPoolBlock
- gpointer available_ptr;
- PurpleMemoryPoolBlock *next;
-static GParamSpec *properties[PROP_LAST];
-G_DEFINE_TYPE_WITH_PRIVATE(PurpleMemoryPool, purple_memory_pool,
-/*******************************************************************************
- * Memory allocation/deallocation
- ******************************************************************************/
-static PurpleMemoryPoolBlock *
-purple_memory_pool_block_new(gulong block_size)
- PurpleMemoryPoolBlock *block;
- /* ceil block struct size to the multiply of align */
- total_size = ((sizeof(PurpleMemoryPoolBlock) - 1) /
- PURPLE_MEMORY_POOL_BLOCK_PADDING + 1) *
- sizeof(PurpleMemoryPoolBlock);
- g_return_val_if_fail(block_size < G_MAXSIZE - total_size, NULL);
- total_size += block_size;
- block_raw = g_try_malloc(total_size);
- g_return_val_if_fail(block_raw != NULL, NULL);
- /* in fact, we don't set available_ptr padded to
- * PURPLE_MEMORY_POOL_BLOCK_PADDING, but we guarantee, there is at least
- * block_size long block if padded to that value. */
- block->available_ptr = PURPLE_MEMORY_POINTER_SHIFT(block_raw,
- sizeof(PurpleMemoryPoolBlock));
- block->end_ptr = PURPLE_MEMORY_POINTER_SHIFT(block_raw, total_size);
-purple_memory_pool_alloc_impl(PurpleMemoryPool *pool, gsize size, guint alignment)
- PurpleMemoryPoolPrivate *priv = NULL;
- PurpleMemoryPoolBlock *blk;
- g_return_val_if_fail(PURPLE_IS_MEMORY_POOL(pool), NULL);
- priv = purple_memory_pool_get_instance_private(pool);
- /* XXX: this may cause some leaks */
- return g_try_malloc(size);
- g_return_val_if_fail(alignment <= PURPLE_MEMORY_POOL_BLOCK_PADDING, NULL);
- g_warn_if_fail(alignment >= 1);
- blk = priv->last_block;
- mem = PURPLE_MEMORY_PADDED(blk->available_ptr, alignment);
- if (mem >= blk->end_ptr)
- else if (mem < blk->available_ptr) /* gpointer overflow */
- else if (PURPLE_MEMORY_POINTER_SHIFT(mem, size) >= blk->end_ptr)
- gsize real_size = priv->block_size;
- blk = purple_memory_pool_block_new(real_size);
- g_return_val_if_fail(blk != NULL, NULL);
- g_assert((priv->first_block == NULL) ==
- (priv->last_block == NULL));
- if (priv->first_block == NULL) {
- priv->first_block = blk;
- priv->last_block = blk;
- priv->last_block->next = blk;
- priv->last_block = blk;
- mem = PURPLE_MEMORY_PADDED(blk->available_ptr, alignment);
- g_assert((guintptr)mem + size < (guintptr)blk->end_ptr);
- g_assert(mem >= blk->available_ptr); /* gpointer overflow */
- blk->available_ptr = PURPLE_MEMORY_POINTER_SHIFT(mem, size);
- g_assert(blk->available_ptr <= blk->end_ptr);
-purple_memory_pool_cleanup_impl(PurpleMemoryPool *pool)
- PurpleMemoryPoolPrivate *priv =
- purple_memory_pool_get_instance_private(pool);
- PurpleMemoryPoolBlock *blk;
- blk = priv->first_block;
- priv->first_block = NULL;
- priv->last_block = NULL;
- PurpleMemoryPoolBlock *next = blk->next;
-/*******************************************************************************
- ******************************************************************************/
-purple_memory_pool_set_block_size(PurpleMemoryPool *pool, gulong block_size)
- PurpleMemoryPoolPrivate *priv = NULL;
- g_return_if_fail(PURPLE_IS_MEMORY_POOL(pool));
- priv = purple_memory_pool_get_instance_private(pool);
- priv->block_size = block_size;
- g_object_notify_by_pspec(G_OBJECT(pool), properties[PROP_BLOCK_SIZE]);
-purple_memory_pool_alloc(PurpleMemoryPool *pool, gsize size, guint alignment)
- PurpleMemoryPoolClass *klass;
- g_return_val_if_fail(PURPLE_IS_MEMORY_POOL(pool), NULL);
- klass = PURPLE_MEMORY_POOL_GET_CLASS(pool);
- g_return_val_if_fail(klass != NULL, NULL);
- g_return_val_if_fail(klass->palloc != NULL, NULL);
- return klass->palloc(pool, size, alignment);
-purple_memory_pool_alloc0(PurpleMemoryPool *pool, gsize size, guint alignment)
- mem = purple_memory_pool_alloc(pool, size, alignment);
- g_return_val_if_fail(mem != NULL, NULL);
-purple_memory_pool_free(PurpleMemoryPool *pool, gpointer mem)
- PurpleMemoryPoolClass *klass;
- g_return_if_fail(PURPLE_IS_MEMORY_POOL(pool));
- klass = PURPLE_MEMORY_POOL_GET_CLASS(pool);
- g_return_if_fail(klass != NULL);
- klass->pfree(pool, mem);
-purple_memory_pool_cleanup(PurpleMemoryPool *pool)
- PurpleMemoryPoolClass *klass;
- g_return_if_fail(PURPLE_IS_MEMORY_POOL(pool));
- klass = PURPLE_MEMORY_POOL_GET_CLASS(pool);
- g_return_if_fail(klass != NULL);
-/*******************************************************************************
- ******************************************************************************/
-purple_memory_pool_new(void)
- return g_object_new(PURPLE_TYPE_MEMORY_POOL, NULL);
-purple_memory_pool_init(PurpleMemoryPool *pool)
- PurpleMemoryPoolPrivate *priv =
- purple_memory_pool_get_instance_private(pool);
- priv->disabled = PURPLE_MEMORY_POOL_DISABLED;
-purple_memory_pool_finalize(GObject *obj)
- purple_memory_pool_cleanup(PURPLE_MEMORY_POOL(obj));
- G_OBJECT_CLASS(purple_memory_pool_parent_class)->finalize(obj);
-purple_memory_pool_get_property(GObject *obj, guint param_id, GValue *value,
- PurpleMemoryPool *pool = PURPLE_MEMORY_POOL(obj);
- PurpleMemoryPoolPrivate *priv =
- purple_memory_pool_get_instance_private(pool);
- g_value_set_ulong(value, priv->block_size);
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-purple_memory_pool_set_property(GObject *obj, guint param_id,
- const GValue *value, GParamSpec *pspec)
- PurpleMemoryPool *pool = PURPLE_MEMORY_POOL(obj);
- PurpleMemoryPoolPrivate *priv =
- purple_memory_pool_get_instance_private(pool);
- priv->block_size = g_value_get_ulong(value);
- G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-purple_memory_pool_class_init(PurpleMemoryPoolClass *klass)
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- obj_class->finalize = purple_memory_pool_finalize;
- obj_class->get_property = purple_memory_pool_get_property;
- obj_class->set_property = purple_memory_pool_set_property;
- klass->palloc = purple_memory_pool_alloc_impl;
- klass->cleanup = purple_memory_pool_cleanup_impl;
- properties[PROP_BLOCK_SIZE] = g_param_spec_ulong("block-size",
- "Block size", "The default size of each block of pool memory.",
- 0, G_MAXULONG, PURPLE_MEMORY_POOL_DEFAULT_BLOCK_SIZE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
- g_object_class_install_properties(obj_class, PROP_LAST, properties);
-purple_memory_pool_strdup(PurpleMemoryPool *pool, const gchar *str)
- g_return_val_if_fail(PURPLE_IS_MEMORY_POOL(pool), NULL);
- str_dup = purple_memory_pool_alloc(pool, str_len + 1, sizeof(gchar));
- g_return_val_if_fail(str_dup != NULL, NULL);
- memcpy(str_dup, str, str_len);
- str_dup[str_len] = '\0';
--- a/libpurple/memorypool.h Mon Sep 12 22:40:17 2022 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,196 +0,0 @@
- * Purple is the legal property of its developers, whose names are too
- * numerous to list here. Please refer to the COPYRIGHT file distributed
- * with this source distribution
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
-#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
-# error "only <purple.h> may be included directly"
-#ifndef PURPLE_MEMORY_POOL_H
-#define PURPLE_MEMORY_POOL_H
-#include <glib-object.h>
-#define PURPLE_TYPE_MEMORY_POOL (purple_memory_pool_get_type())
-#define PURPLE_MEMORY_POOL(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_MEMORY_POOL, PurpleMemoryPool))
-#define PURPLE_MEMORY_POOL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_MEMORY_POOL, PurpleMemoryPoolClass))
-#define PURPLE_IS_MEMORY_POOL(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_MEMORY_POOL))
-#define PURPLE_IS_MEMORY_POOL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_MEMORY_POOL))
-#define PURPLE_MEMORY_POOL_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_MEMORY_POOL, PurpleMemoryPoolClass))
-typedef struct _PurpleMemoryPool PurpleMemoryPool;
-typedef struct _PurpleMemoryPoolClass PurpleMemoryPoolClass;
- * A #PurpleMemoryPool allows allocating many small objects within a single
- * memory range and releasing them all at once using a single call. This
- * prevents memory fragmentation and improves performance when used properly.
- * Its purpose is to act as an internal storage for other object private
- * structures, like tree nodes, string chunks, list elements.
- * Current implementation is not optimized for releasing individual objects,
- * so it may be extremely inefficient, when misused. On every memory allocation,
- * it checks if there is enough space in current block. If there is not enough
- * room here, it creates another block of memory. On pool destruction or calling
- * #purple_memory_pool_cleanup, the whole block chain will be freed, using only
- * one #g_free call for every block.
-struct _PurpleMemoryPool
- GObject parent_instance;
- * PurpleMemoryPoolClass:
- * @palloc: alloates memory for a specific memory pool subclass,
- * see #purple_memory_pool_alloc.
- * @pfree: frees memory allocated within a pool, see #purple_memory_pool_free.
- * @cleanup: frees (or marks as unused) all memory allocated within a pool.
- * See #purple_memory_pool_cleanup.
- * Base class for #PurpleMemoryPool objects.
-struct _PurpleMemoryPoolClass
- GObjectClass parent_class;
- gpointer (*palloc)(PurpleMemoryPool *pool, gsize size, guint alignment);
- gpointer (*pfree)(PurpleMemoryPool *pool, gpointer mem);
- void (*cleanup)(PurpleMemoryPool *pool);
- void (*purple_reserved1)(void);
- void (*purple_reserved2)(void);
- void (*purple_reserved3)(void);
- void (*purple_reserved4)(void);
- * purple_memory_pool_get_type:
- * Returns: the #GType for a #PurpleMemoryPool.
-purple_memory_pool_get_type(void);
- * purple_memory_pool_new:
- * Creates a new memory pool.
- * Returns: the new #PurpleMemoryPool.
-purple_memory_pool_new(void);
- * purple_memory_pool_set_block_size:
- * @pool: the memory pool.
- * @block_size: the new default block size.
- * Sets new default block size for a memory pool. You might want to call this
- * before any allocation, to have it applied to the every created block.
-purple_memory_pool_set_block_size(PurpleMemoryPool *pool, gulong block_size);
- * purple_memory_pool_alloc:
- * @pool: the memory pool.
- * @size: the size of memory to be allocated.
- * @alignment: the alignment of memory block (should be a power of two).
- * Allocates an aligned memory block within a pool.
- * Returns: the pointer to a memory block. This should be freed with
- * a call to #purple_memory_pool_free.
-purple_memory_pool_alloc(PurpleMemoryPool *pool, gsize size, guint alignment);
- * purple_memory_pool_alloc0:
- * @pool: the memory pool.
- * @size: the size of memory to be allocated.
- * @alignment: the alignment of memory block (should be a power of two).
- * Allocates an aligned memory block within a pool and sets its contents to
- * Returns: the pointer to a memory block. This should be freed with
- * a call to #purple_memory_pool_free.
-purple_memory_pool_alloc0(PurpleMemoryPool *pool, gsize size, guint alignment);
- * purple_memory_pool_free:
- * @pool: the memory pool.
- * @mem: the pointer to a memory block.
- * Frees a memory allocated within a memory pool. This can be a no-op in certain
- * implementations. Thus, it don't need to be called in every case. Thus, the
- * freed memory is wasted until you call #purple_memory_pool_cleanup
- * or destroy the @pool.
-purple_memory_pool_free(PurpleMemoryPool *pool, gpointer mem);
- * purple_memory_pool_cleanup:
- * @pool: the memory pool.
- * Marks all memory allocated within a memory pool as not used. It may free
- * resources, but don't have to.
-purple_memory_pool_cleanup(PurpleMemoryPool *pool);
- * purple_memory_pool_strdup:
- * @pool: the memory pool.
- * @str: the string to duplicate.
- * Duplicates a string using a memory allocated within a memory pool. If @str is
- * %NULL, it returns %NULL. The returned string should be freed with g_free()
- * when no longer needed.
- * Returns: a newly-allocated copy of @str.
-purple_memory_pool_strdup(PurpleMemoryPool *pool, const gchar *str);
-#endif /* PURPLE_MEMORY_POOL_H */
--- a/libpurple/meson.build Mon Sep 12 22:40:17 2022 -0500
+++ b/libpurple/meson.build Mon Sep 12 22:49:11 2022 -0500
@@ -26,7 +26,6 @@
@@ -128,7 +127,6 @@
--- a/po/POTFILES.in Mon Sep 12 22:40:17 2022 -0500
+++ b/po/POTFILES.in Mon Sep 12 22:49:11 2022 -0500
@@ -48,7 +48,6 @@
libpurple/media/enum-types.c