/*
* Get the next element in the list
*/
-#define List_Next_Entry(pos, member) \
- List_Entry((pos)->member.next, Q_typeof(*(pos)), member)
+#define List_Next_Entry(pos, type, member) \
+ List_Entry((pos)->member.next, type, member)
/*
* Get the prev element in the list
*/
-#define List_Prev_Entry(pos, member) \
- List_Entry((pos)->member.prev, Q_typeof(*(pos)), member)
+#define List_Prev_Entry(pos, type, member) \
+ List_Entry((pos)->member.prev, type, member)
/*
* Iterate over a list
/*
* Iterate over a list of a given type
*/
-#define List_For_Each_Entry(pos, head, member) \
- for (pos = List_First_Entry(head, Q_typeof(*pos), member); \
+#define List_For_Each_Entry(pos, head, type, member) \
+ for (pos = List_First_Entry(head, type, member); \
!List_Entry_Is_Head(pos, head, member); \
- pos = List_Next_Entry(pos, member))
+ pos = List_Next_Entry(pos, type, member))
/*
* Iterate over a list of a given type backwards
*/
-#define List_For_Each_Prev_Entry(pos, head, member) \
- for (pos = List_Last_Entry(head, Q_typeof(*pos), member); \
+#define List_For_Each_Prev_Entry(pos, head, type, member) \
+ for (pos = List_Last_Entry(head, type, member); \
!List_Entry_Is_Head(pos, head, member); \
- pos = List_Prev_Entry(pos, member))
+ pos = List_Prev_Entry(pos, type, member))
/*
* Prepares a pos entry for use as a start point in List_For_Each_Entry_Continue()
*/
-#define List_Prepare_Entry(pos, head, member) \
- ((pos) ? : List_Entry(head, Q_typeof(*pos), member))
+#define List_Prepare_Entry(pos, head, type, member) \
+ ((pos) ? : List_Entry(head, type, member))
/*
* Continue iteration over a list of a given type, after the current position
*/
-#define List_For_Each_Entry_Continue(pos, head, member) \
- for (pos = List_Next_Entry(pos, member); \
+#define List_For_Each_Entry_Continue(pos, head, type, member) \
+ for (pos = List_Next_Entry(pos, type, member); \
!List_Entry_Is_Head(pos, head, member); \
- pos = List_Next_Entry(pos, member))
+ pos = List_Next_Entry(pos, type, member))
/*
* Continue iteration over a list of a given type backwards, after the current position
*/
-#define List_For_Each_Prev_Entry_Continue(pos, head, member) \
- for (pos = List_Prev_Entry(pos, member); \
+#define List_For_Each_Prev_Entry_Continue(pos, head, type, member) \
+ for (pos = List_Prev_Entry(pos, type, member); \
!List_Entry_Is_Head(pos, head, member); \
- pos = List_Prev_Entry(pos, member))
+ pos = List_Prev_Entry(pos, type, member))
/*
* Continue iteration over a list of a given type, from the current position
*/
-#define List_For_Each_Entry_From(pos, head, member) \
+#define List_For_Each_Entry_From(pos, head, type, member) \
for (; !List_Entry_Is_Head(pos, head, member); \
- pos = List_Next_Entry(pos, member))
+ pos = List_Next_Entry(pos, type, member))
/*
* Continue iteration over a list of a given type backwards, from the current position
*/
-#define List_For_Each_Prev_Entry_From(pos, head, member) \
+#define List_For_Each_Prev_Entry_From(pos, head, type, member) \
for (; !List_Entry_Is_Head(pos, head, member); \
- pos = List_Prev_Entry(pos, member))
+ pos = List_Prev_Entry(pos, type, member))
/*
* Iterate over a list of a given type, safe against removal of list entry
*/
-#define List_For_Each_Entry_Safe(pos, n, head, member) \
- for (pos = List_First_Entry(head, Q_typeof(*pos), member), \
- n = List_Next_Entry(pos, member); \
+#define List_For_Each_Entry_Safe(pos, n, head, type, member) \
+ for (pos = List_First_Entry(head, type, member), \
+ n = List_Next_Entry(pos, type, member); \
!List_Entry_Is_Head(pos, head, member); \
- pos = n, n = List_Next_Entry(n, member))
+ pos = n, n = List_Next_Entry(n, type, member))
/*
* Continue iteration over a list of a given type, after the current position, safe against removal of list entry
*/
-#define List_For_Each_Entry_Safe_Continue(pos, n, head, member) \
- for (pos = List_Next_Entry(pos, member), \
- n = List_Next_Entry(pos, member); \
+#define List_For_Each_Entry_Safe_Continue(pos, n, head, type, member) \
+ for (pos = List_Next_Entry(pos, type, member), \
+ n = List_Next_Entry(pos, type, member); \
!List_Entry_Is_Head(pos, head, member); \
- pos = n, n = List_Next_Entry(n, member))
+ pos = n, n = List_Next_Entry(n, type, member))
/*
* Continue iteration over a list of a given type, from the current position, safe against removal of list entry
*/
-#define List_For_Each_Entry_Safe_From(pos, n, head, member) \
- for (n = List_Next_Entry(pos, member); \
+#define List_For_Each_Entry_Safe_From(pos, n, head, type, member) \
+ for (n = List_Next_Entry(pos, type, member); \
!List_Entry_Is_Head(pos, head, member); \
- pos = n, n = List_Next_Entry(n, member))
+ pos = n, n = List_Next_Entry(n, type, member))
/*
* Iterate over a list of a given type backwards, safe against removal of list entry
*/
-#define List_For_Each_Prev_Entry_Safe(pos, n, head, member) \
- for (pos = List_Last_Entry(head, Q_typeof(*pos), member), \
- n = List_Prev_Entry(pos, member); \
+#define List_For_Each_Prev_Entry_Safe(pos, n, head, type, member) \
+ for (pos = List_Last_Entry(head, type, member), \
+ n = List_Prev_Entry(pos, type, member); \
!List_Entry_Is_Head(pos, head, member); \
- pos = n, n = List_Prev_Entry(n, member))
+ pos = n, n = List_Prev_Entry(n, type, member))
/*
* Reset a stale List_For_Each_Entry_Safe loop
*/
-#define List_Safe_Reset_Next(pos, n, member) \
- n = List_Next_Entry(pos, member)
+#define List_Safe_Reset_Next(pos, n, type, member) \
+ n = List_Next_Entry(pos, type, member)
static inline qbool List_Is_Empty(const llist_t *list)
{
lhnetpacket_t *p, *pnext;
if (!lhnet_active)
return;
- List_For_Each_Entry_Safe(s, snext, &lhnet_socketlist.list, list)
+ List_For_Each_Entry_Safe(s, snext, &lhnet_socketlist.list, lhnetsocket_t, list)
LHNET_CloseSocket(s);
- List_For_Each_Entry_Safe(p, pnext, &lhnet_packetlist.list, list)
+ List_For_Each_Entry_Safe(p, pnext, &lhnet_packetlist.list, lhnetpacket_t, list)
{
List_Delete(&p->list);
Z_Free(p);
lhnetsocket_t *s;
FD_ZERO(&fdreadset);
lastfd = 0;
- List_For_Each_Entry(s, &lhnet_socketlist.list, list)
+ List_For_Each_Entry(s, &lhnet_socketlist.list, lhnetsocket_t, list)
{
if (s->address.addresstype == LHNETADDRESSTYPE_INET4 || s->address.addresstype == LHNETADDRESSTYPE_INET6)
{
lhnetsocket->address.port = 1024;
for (;;)
{
- List_For_Each_Entry(s, &lhnet_socketlist.list, list)
+ List_For_Each_Entry(s, &lhnet_socketlist.list, lhnetsocket_t, list)
if (s->address.addresstype == lhnetsocket->address.addresstype && s->address.port == lhnetsocket->address.port)
break;
if (s == &lhnet_socketlist)
}
}
// check if the port is available
- List_For_Each_Entry(s, &lhnet_socketlist.list, list)
+ List_For_Each_Entry(s, &lhnet_socketlist.list, lhnetsocket_t, list)
if (s->address.addresstype == lhnetsocket->address.addresstype && s->address.port == lhnetsocket->address.port)
break;
if (s == &lhnet_socketlist && lhnetsocket->address.port != 0)
// scan for any old packets to timeout while searching for a packet
// that is waiting to be delivered to this socket
currenttime = time(NULL);
- List_For_Each_Entry_Safe(p, pnext, &lhnet_packetlist.list, list)
+ List_For_Each_Entry_Safe(p, pnext, &lhnet_packetlist.list, lhnetpacket_t, list)
{
if (p->timeout < currenttime)
{
if(noclear)
return;
if (curl_mutex) Thread_LockMutex(curl_mutex);
- List_For_Each_Entry(di, &downloads, list)
+ List_For_Each_Entry(di, &downloads, downloadinfo, list)
di->forthismap = false;
Curl_CommandWhenError(NULL);
Curl_CommandWhenDone(NULL);
if(numdownloads < cl_curl_maxdownloads.integer)
{
downloadinfo *di;
- List_For_Each_Entry(di, &downloads, list)
+ List_For_Each_Entry(di, &downloads, downloadinfo, list)
{
if(!di->started)
{
downloadinfo *di;
if(!curl_dll)
return NULL;
- List_For_Each_Entry(di, &downloads, list)
+ List_For_Each_Entry(di, &downloads, downloadinfo, list)
if(!strcasecmp(di->filename, filename))
return di;
return NULL;
downloadinfo *di, *ndi;
if(!curl_dll)
return;
- List_For_Each_Entry_Safe(di, ndi, &downloads, list)
+ List_For_Each_Entry_Safe(di, ndi, &downloads, downloadinfo, list)
{
if(di->callback == callback && di->callback_data == cbdata)
{
}
while(mc == CURLM_CALL_MULTI_PERFORM);
- List_For_Each_Entry(di, &downloads, list)
+ List_For_Each_Entry(di, &downloads, downloadinfo, list)
{
double b = 0;
if(di->curle)
// use the slowest allowing download to derive the maxspeed... this CAN
// be done better, but maybe later
maxspeed = cl_curl_maxspeed.value;
- List_For_Each_Entry(di, &downloads, list)
+ List_For_Each_Entry(di, &downloads, downloadinfo, list)
if(di->maxspeed > 0)
if(di->maxspeed < maxspeed || maxspeed <= 0)
maxspeed = di->maxspeed;
{
if (curl_mutex) Thread_LockMutex(curl_mutex);
Con_Print("Currently running downloads:\n");
- List_For_Each_Entry(di, &downloads, list)
+ List_For_Each_Entry(di, &downloads, downloadinfo, list)
{
double speed, percent;
Con_Printf(" %s -> %s ", CleanURL(di->url, urlbuf, sizeof(urlbuf)), di->filename);
if (curl_mutex) Thread_LockMutex(curl_mutex);
i = 0;
- List_For_Each_Entry(di, &downloads, list)
+ List_For_Each_Entry(di, &downloads, downloadinfo, list)
++i;
downinfo = (Curl_downloadinfo_t *) Z_Malloc(sizeof(*downinfo) * i);
i = 0;
- List_For_Each_Entry(di, &downloads, list)
+ List_For_Each_Entry(di, &downloads, downloadinfo, list)
{
// do not show infobars for background downloads
if(developer.integer <= 0)
Sys_Error("Mem_CheckSentinelsGlobal: trashed pool sentinel 2 (allocpool at %s:%i, sentinel check at %s:%i)", pool->filename, pool->fileline, filename, fileline);
}
for (pool = poolchain;pool;pool = pool->next)
- List_For_Each_Entry(mem, &pool->chain, list)
+ List_For_Each_Entry(mem, &pool->chain, memheader_t, list)
_Mem_CheckSentinels((void *)((unsigned char *) mem + sizeof(memheader_t)), filename, fileline);
#if MEMCLUMPING
for (pool = poolchain;pool;pool = pool->next)
{
// search only one pool
target = (memheader_t *)((unsigned char *) data - sizeof(memheader_t));
- List_For_Each_Entry(header, &pool->chain, list)
+ List_For_Each_Entry(header, &pool->chain, memheader_t, list)
if( header == target )
return true;
}
if ((pool->flags & POOLFLAG_TEMP) && !List_Is_Empty(&pool->chain))
{
Con_Printf("Memory pool %p has sprung a leak totalling %lu bytes (%.3fMB)! Listing contents...\n", (void *)pool, (unsigned long)pool->totalsize, pool->totalsize / 1048576.0);
- List_For_Each_Entry(mem, &pool->chain, list)
+ List_For_Each_Entry(mem, &pool->chain, memheader_t, list)
Con_Printf("%10lu bytes allocated at %s:%i\n", (unsigned long)mem->size, mem->filename, mem->fileline);
}
}
{
Con_Printf("%10luk (%10luk actual) %s (%+li byte change) %s\n", (unsigned long) ((pool->totalsize + 1023) / 1024), (unsigned long)((pool->realsize + 1023) / 1024), pool->name, (long)(pool->totalsize - pool->lastchecksize), (pool->flags & POOLFLAG_TEMP) ? "TEMP" : "");
pool->lastchecksize = pool->totalsize;
- List_For_Each_Entry(mem, &pool->chain, list)
+ List_For_Each_Entry(mem, &pool->chain, memheader_t, list)
if (mem->size >= minallocationsize)
Con_Printf("%10lu bytes allocated at %s:%i\n", (unsigned long)mem->size, mem->filename, mem->fileline);
}