mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-03 20:42:48 -05:00
Rename FROMFIELD to 'container_of'.
Ian Jackson points out that the Linux kernel has a macro of this name with the same purpose, and suggests that it's a good idea to use the same name as they do, so that at least some people reading one code base might recognise it from the other. I never really thought very hard about what order FROMFIELD's parameters should go in, and therefore I'm pleasantly surprised to find that my order agrees with the kernel's, so I don't have to permute every call site as part of making this change :-)
This commit is contained in:
@ -59,7 +59,7 @@ static void pktin_free_queue_callback(void *vctx)
|
||||
{
|
||||
while (pktin_freeq_head.next != &pktin_freeq_head) {
|
||||
PacketQueueNode *node = pktin_freeq_head.next;
|
||||
PktIn *pktin = FROMFIELD(node, PktIn, qnode);
|
||||
PktIn *pktin = container_of(node, PktIn, qnode);
|
||||
pktin_freeq_head.next = node->next;
|
||||
sfree(pktin);
|
||||
}
|
||||
@ -89,7 +89,7 @@ static PktIn *pq_in_get(PacketQueueBase *pqb, int pop)
|
||||
queue_idempotent_callback(&ic_pktin_free);
|
||||
}
|
||||
|
||||
return FROMFIELD(node, PktIn, qnode);
|
||||
return container_of(node, PktIn, qnode);
|
||||
}
|
||||
|
||||
static PktOut *pq_out_get(PacketQueueBase *pqb, int pop)
|
||||
@ -104,7 +104,7 @@ static PktOut *pq_out_get(PacketQueueBase *pqb, int pop)
|
||||
node->prev = node->next = NULL;
|
||||
}
|
||||
|
||||
return FROMFIELD(node, PktOut, qnode);
|
||||
return container_of(node, PktOut, qnode);
|
||||
}
|
||||
|
||||
void pq_in_init(PktInQueue *pq)
|
||||
|
Reference in New Issue
Block a user