1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 17:47:37 +00:00

refactor: remove unused tr_list code (#1849)

This commit is contained in:
Charles Kerr 2021-09-27 17:57:20 -05:00 committed by GitHub
parent 16a70e57d2
commit 7d2f65455c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 0 additions and 358 deletions

View file

@ -371,8 +371,6 @@
C1FEE57B1C3223CC00D62832 /* watchdir.h in Headers */ = {isa = PBXBuildFile; fileRef = C1FEE5761C3223CC00D62832 /* watchdir.h */; };
CAB35C64252F6F5E00552A55 /* mime-types.h in Headers */ = {isa = PBXBuildFile; fileRef = CAB35C62252F6F5E00552A55 /* mime-types.h */; };
CAB35C65252F6F5E00552A55 /* mime-types.cc in Sources */ = {isa = PBXBuildFile; fileRef = CAB35C63252F6F5E00552A55 /* mime-types.cc */; };
D4AF3B2F0C41F7A500D46B6B /* list.cc in Sources */ = {isa = PBXBuildFile; fileRef = D4AF3B2D0C41F7A500D46B6B /* list.cc */; };
D4AF3B300C41F7A600D46B6B /* list.h in Headers */ = {isa = PBXBuildFile; fileRef = D4AF3B2E0C41F7A500D46B6B /* list.h */; };
E138A9780C04D88F00C5426C /* ProgressGradients.mm in Sources */ = {isa = PBXBuildFile; fileRef = E138A9760C04D88F00C5426C /* ProgressGradients.mm */; };
EDBDFA9E25AFCCA60093D9C1 /* evutil_time.c in Sources */ = {isa = PBXBuildFile; fileRef = EDBDFA9D25AFCCA60093D9C1 /* evutil_time.c */; };
F63480631E1D7274005B9E09 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F63480621E1D7274005B9E09 /* Images.xcassets */; };
@ -1034,8 +1032,6 @@
C1FEE5761C3223CC00D62832 /* watchdir.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = watchdir.h; sourceTree = "<group>"; };
CAB35C62252F6F5E00552A55 /* mime-types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "mime-types.h"; sourceTree = "<group>"; };
CAB35C63252F6F5E00552A55 /* mime-types.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "mime-types.cc"; sourceTree = "<group>"; };
D4AF3B2D0C41F7A500D46B6B /* list.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = list.cc; sourceTree = "<group>"; };
D4AF3B2E0C41F7A500D46B6B /* list.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = list.h; sourceTree = "<group>"; };
E138A9750C04D88F00C5426C /* ProgressGradients.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProgressGradients.h; sourceTree = "<group>"; };
E138A9760C04D88F00C5426C /* ProgressGradients.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ProgressGradients.mm; sourceTree = "<group>"; };
EDBDFA9D25AFCCA60093D9C1 /* evutil_time.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = evutil_time.c; sourceTree = "<group>"; };
@ -1449,8 +1445,6 @@
A24621350C769CF400088E81 /* trevent.h */,
A24621360C769CF400088E81 /* trevent.cc */,
4394AC640C74FB6000F367E8 /* ptrarray.cc */,
D4AF3B2D0C41F7A500D46B6B /* list.cc */,
D4AF3B2E0C41F7A500D46B6B /* list.h */,
A2BE9C4E0C1E4ADA002D16E6 /* makemeta.cc */,
A2BE9C4F0C1E4ADA002D16E6 /* makemeta.h */,
BEFC1DF00C07861A00B0BB3C /* version.h */,
@ -1874,7 +1868,6 @@
BEFC1E550C07861A00B0BB3C /* completion.h in Headers */,
BEFC1E570C07861A00B0BB3C /* clients.h in Headers */,
A2BE9C530C1E4AF7002D16E6 /* makemeta.h in Headers */,
D4AF3B300C41F7A600D46B6B /* list.h in Headers */,
A24621410C769D0900088E81 /* trevent.h in Headers */,
4D36BA700CA2F00800A63CA5 /* crypto.h in Headers */,
C10C644E1D9AF328003C1B4C /* session-id.h in Headers */,
@ -2464,7 +2457,6 @@
BEFC1E560C07861A00B0BB3C /* completion.cc in Sources */,
BEFC1E580C07861A00B0BB3C /* clients.cc in Sources */,
A2BE9C520C1E4AF5002D16E6 /* makemeta.cc in Sources */,
D4AF3B2F0C41F7A500D46B6B /* list.cc in Sources */,
4394AC670C74FB6000F367E8 /* ptrarray.cc in Sources */,
A24621420C769D0900088E81 /* trevent.cc in Sources */,
C11DEA161FCD31C0009E22B9 /* subprocess-posix.cc in Sources */,

View file

@ -29,7 +29,6 @@ set(PROJECT_FILES
handshake.cc
history.cc
inout.cc
list.cc
log.cc
magnet.cc
makemeta.cc
@ -155,7 +154,6 @@ set(${PROJECT_NAME}_PRIVATE_HEADERS
handshake.h
history.h
inout.h
list.h
magnet.h
metainfo.h
mime-types.h

View file

@ -1,246 +0,0 @@
/*
* This file Copyright (C) 2007-2014 Mnemosyne LLC
*
* It may be used under the GNU GPL versions 2 or 3
* or any future license endorsed by Mnemosyne LLC.
*
*/
#include "transmission.h"
#include "list.h"
#include "platform.h"
#include "utils.h"
static tr_list* recycled_nodes = nullptr;
static tr_lock* getRecycledNodesLock(void)
{
static tr_lock* l = nullptr;
if (l == nullptr)
{
l = tr_lockNew();
}
return l;
}
static tr_list* node_alloc(void)
{
tr_list* ret = nullptr;
tr_lock* lock = getRecycledNodesLock();
tr_lockLock(lock);
if (recycled_nodes != nullptr)
{
ret = recycled_nodes;
recycled_nodes = recycled_nodes->next;
}
tr_lockUnlock(lock);
if (ret == nullptr)
{
ret = tr_new(tr_list, 1);
}
*ret = {};
return ret;
}
static void node_free(tr_list* node)
{
tr_lock* lock = getRecycledNodesLock();
if (node != nullptr)
{
*node = {};
tr_lockLock(lock);
node->next = recycled_nodes;
recycled_nodes = node;
tr_lockUnlock(lock);
}
}
/***
****
***/
void tr_list_free(tr_list** list, TrListForeachFunc data_free_func)
{
while (*list != nullptr)
{
tr_list* node = *list;
*list = (*list)->next;
if (data_free_func != nullptr)
{
data_free_func(node->data);
}
node_free(node);
}
}
void tr_list_prepend(tr_list** list, void* data)
{
tr_list* node = node_alloc();
node->data = data;
node->next = *list;
if (*list != nullptr)
{
(*list)->prev = node;
}
*list = node;
}
void tr_list_append(tr_list** list, void* data)
{
tr_list* node = node_alloc();
node->data = data;
if (*list == nullptr)
{
*list = node;
}
else
{
tr_list* l = *list;
while (l->next != nullptr)
{
l = l->next;
}
l->next = node;
node->prev = l;
}
}
static tr_list* tr_list_find_data(tr_list* list, void const* data)
{
for (; list != nullptr; list = list->next)
{
if (list->data == data)
{
return list;
}
}
return nullptr;
}
static void* tr_list_remove_node(tr_list** list, tr_list* node)
{
void* data;
tr_list* prev = node != nullptr ? node->prev : nullptr;
tr_list* next = node != nullptr ? node->next : nullptr;
if (prev != nullptr)
{
prev->next = next;
}
if (next != nullptr)
{
next->prev = prev;
}
if (*list == node)
{
*list = next;
}
data = node != nullptr ? node->data : nullptr;
node_free(node);
return data;
}
void* tr_list_pop_front(tr_list** list)
{
void* ret = nullptr;
if (*list != nullptr)
{
ret = (*list)->data;
tr_list_remove_node(list, *list);
}
return ret;
}
void* tr_list_remove_data(tr_list** list, void const* data)
{
return tr_list_remove_node(list, tr_list_find_data(*list, data));
}
void* tr_list_remove(tr_list** list, void const* b, TrListCompareFunc compare_func)
{
return tr_list_remove_node(list, tr_list_find(*list, b, compare_func));
}
tr_list* tr_list_find(tr_list* list, void const* b, TrListCompareFunc func)
{
for (; list != nullptr; list = list->next)
{
if (func(list->data, b) == 0)
{
return list;
}
}
return nullptr;
}
void tr_list_insert_sorted(tr_list** list, void* data, TrListCompareFunc compare)
{
/* find the node that we'll insert this data before */
tr_list* next_node = nullptr;
for (tr_list* l = *list; l != nullptr; l = l->next)
{
int const c = (*compare)(data, l->data);
if (c <= 0)
{
next_node = l;
break;
}
}
if (next_node == nullptr)
{
tr_list_append(list, data);
}
else if (next_node == *list)
{
tr_list_prepend(list, data);
}
else
{
tr_list* node = node_alloc();
node->data = data;
node->prev = next_node->prev;
node->next = next_node;
node->prev->next = node;
node->next->prev = node;
}
}
int tr_list_size(tr_list const* list)
{
int size = 0;
while (list != nullptr)
{
++size;
list = list->next;
}
return size;
}

View file

@ -1,101 +0,0 @@
/*
* This file Copyright (C) 2007-2014 Mnemosyne LLC
*
* It may be used under the GNU GPL versions 2 or 3
* or any future license endorsed by Mnemosyne LLC.
*
*/
#pragma once
#ifndef __TRANSMISSION__
#error only libtransmission should #include this header.
#endif
/**
* @addtogroup utils Utilities
* @{
*/
#include "transmission.h" /* inline */
/** @brief simple list structure similar to glib's GList */
typedef struct tr_list
{
void* data;
struct tr_list* next;
struct tr_list* prev;
} tr_list;
typedef tr_voidptr_compare_func TrListCompareFunc;
typedef void (*TrListForeachFunc)(void*);
/**
* @brief return the number of items in the list
* @return the number of items in the list
*/
int tr_list_size(tr_list const* list);
/**
* @brief free the specified list and set its pointer to NULL
* @param list pointer to the list to be freed
* @param func optional function to invoke on each item in the list
*/
void tr_list_free(tr_list** list, TrListForeachFunc data_free_func);
/**
* @brief append an item to the specified list
* @param list pointer to the list
* @param item the item to append
*/
void tr_list_append(tr_list** list, void* data);
/**
* @brief prepend an item to the specified list
* @param list pointer to the list
* @param item the item to prepend
*/
void tr_list_prepend(tr_list** list, void* data);
/**
* @brief remove the next item in the list
* @return the next item in the list, or NULL if the list is empty
* @param list pointer to the list
*/
void* tr_list_pop_front(tr_list** list);
/**
* @brief remove the list's node that contains the specified data pointer
* @param list pointer to the list
* @param data data to remove
* @return the removed data pointer, or NULL if no match was found
*/
void* tr_list_remove_data(tr_list** list, void const* data);
/**
* @brief remove the list's node that compares equal to "b" when compared with "compare_func"
* @param list pointer to the list
* @param b the comparison key
* @param compare_func the comparison function. The arguments passed to it will be the list's pointers and the comparison key "b"
* @return the removed data pointer, or NULL if no match was found
*/
void* tr_list_remove(tr_list** list, void const* b, TrListCompareFunc compare_func);
/**
* @brief find the list node whose data that compares equal to "b" when compared with "compare_func"
* @param list pointer to the list
* @param b the comparison key
* @param compare_func the comparison function. The arguments passed to it will be the list's pointers and the comparison key "b"
* @return the matching list node, or NULL if not match was found
*/
tr_list* tr_list_find(tr_list* list, void const* b, TrListCompareFunc compare_func);
/**
* @brief Insert in an ordered list
* @param list pointer to the list
* @param item the item to be inserted
* @param compare the comparison function.
*/
void tr_list_insert_sorted(tr_list** list, void* data, TrListCompareFunc compare);
/* @} */

View file

@ -58,7 +58,6 @@
#include "error-types.h"
#include "file.h"
#include "ConvertUTF.h"
#include "list.h"
#include "log.h"
#include "mime-types.h"
#include "net.h"