Capi doesn't use dList anymore.
This commit is contained in:
+16
-15
@@ -37,7 +37,8 @@
|
||||
/* for testing dpi chat */
|
||||
#include "bookmark.hh"
|
||||
|
||||
typedef struct {
|
||||
struct capi_conn_t
|
||||
{
|
||||
DilloUrl *url; /**< local copy of web->url */
|
||||
void *bw;
|
||||
char *server;
|
||||
@@ -48,7 +49,7 @@ typedef struct {
|
||||
ChainLink *InfoRecv;
|
||||
|
||||
int Ref;
|
||||
} capi_conn_t;
|
||||
};
|
||||
|
||||
/** Flags for conn */
|
||||
enum {
|
||||
@@ -61,7 +62,7 @@ enum {
|
||||
* Local data
|
||||
*/
|
||||
/** Data list for active dpi connections */
|
||||
static Dlist *CapiConns; /* Data list for active connections; it holds
|
||||
static std::vector< capi_conn_t * > CapiConns; /* Data list for active connections; it holds
|
||||
* pointers to capi_conn_t structures. */
|
||||
/** Last URL asked for view source */
|
||||
static DilloUrl *CapiVsUrl = NULL;
|
||||
@@ -80,8 +81,6 @@ void a_Capi_ccc(int Op, int Branch, int Dir, ChainLink *Info,
|
||||
*/
|
||||
void a_Capi_init(void)
|
||||
{
|
||||
/* create an empty list */
|
||||
CapiConns = dList_new(32);
|
||||
/* init cache */
|
||||
a_Cache_init();
|
||||
}
|
||||
@@ -115,7 +114,8 @@ static capi_conn_t *
|
||||
*/
|
||||
static capi_conn_t *Capi_conn_valid(capi_conn_t *conn)
|
||||
{
|
||||
return reinterpret_cast< capi_conn_t * >( dList_find(CapiConns, conn) );
|
||||
auto found= std::find( begin( CapiConns ), end( CapiConns ), conn );
|
||||
return found == end( CapiConns ) ? nullptr : *found;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,7 +125,7 @@ static void Capi_conn_ref(capi_conn_t *conn)
|
||||
{
|
||||
if (++conn->Ref == 1) {
|
||||
/* add the connection data to list */
|
||||
dList_append(CapiConns, (void *)conn);
|
||||
CapiConns.push_back( conn );
|
||||
}
|
||||
_MSG(" Capi_conn_ref #%d %p\n", conn->Ref, conn);
|
||||
}
|
||||
@@ -140,7 +140,7 @@ static void Capi_conn_unref(capi_conn_t *conn)
|
||||
/* We may validate conn here, but it doesn't *seem* necessary */
|
||||
if (--conn->Ref == 0) {
|
||||
/* remove conn preserving the list order */
|
||||
dList_remove(CapiConns, (void *)conn);
|
||||
CapiConns.erase( std::find( begin( CapiConns ), end( CapiConns ), conn ) );
|
||||
/* free dynamic memory */
|
||||
delete conn->url;
|
||||
dFree(conn->server);
|
||||
@@ -153,7 +153,7 @@ static void Capi_conn_unref(capi_conn_t *conn)
|
||||
/**
|
||||
* Compare function for searching a conn by server string
|
||||
*/
|
||||
static int Capi_conn_by_server_cmp(const void *v1, const void *v2)
|
||||
static int Capi_conn_by_server_cmp(const capi_conn_t *v1, const char *v2)
|
||||
{
|
||||
const capi_conn_t *node = reinterpret_cast< const capi_conn_t * >( v1 );
|
||||
const char *server = reinterpret_cast< const char * >( v2 );
|
||||
@@ -164,9 +164,10 @@ static int Capi_conn_by_server_cmp(const void *v1, const void *v2)
|
||||
/**
|
||||
* Find connection data by server
|
||||
*/
|
||||
static capi_conn_t *Capi_conn_find(char *server)
|
||||
static capi_conn_t *Capi_conn_find(const char *const server)
|
||||
{
|
||||
return reinterpret_cast< capi_conn_t * >( dList_find_custom(CapiConns, (void*)server, Capi_conn_by_server_cmp) );
|
||||
const auto found= std::find_if( begin( CapiConns ), end( CapiConns ), [server]( const auto &node ) { return node->server == server; } );
|
||||
return *found;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,8 +179,8 @@ static void Capi_conn_resume(void)
|
||||
DataBuf *dbuf;
|
||||
capi_conn_t *conn;
|
||||
|
||||
for (i = 0; i < dList_length(CapiConns); ++i) {
|
||||
conn = reinterpret_cast< capi_conn_t * >( dList_nth_data (CapiConns, i) );
|
||||
for (i = 0; i < CapiConns.size(); ++i) {
|
||||
conn = CapiConns.at( i );
|
||||
if (conn->Flags & PENDING) {
|
||||
dbuf = a_Chain_dbuf_new(conn->datastr,(int)strlen(conn->datastr), 0);
|
||||
if (conn->InfoSend) {
|
||||
@@ -202,8 +203,8 @@ void a_Capi_conn_abort_by_url(const DilloUrl *url)
|
||||
int i;
|
||||
capi_conn_t *conn;
|
||||
|
||||
for (i = 0; i < dList_length(CapiConns); ++i) {
|
||||
conn = reinterpret_cast< capi_conn_t * >( dList_nth_data (CapiConns, i) );
|
||||
for (i = 0; i < CapiConns.size(); ++i) {
|
||||
conn = CapiConns.at( i );
|
||||
if (a_Url_cmp(conn->url, url) == 0) {
|
||||
if (conn->InfoSend) {
|
||||
a_Capi_ccc(OpAbort, 1, BCK, conn->InfoSend, NULL, NULL);
|
||||
|
||||
Reference in New Issue
Block a user