lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [lwip-devel] [bug #3031] Implement a new fully pool-basedpbufimpleme


From: Grubb, Jared
Subject: RE: [lwip-devel] [bug #3031] Implement a new fully pool-basedpbufimplementation.
Date: Wed, 25 Jul 2007 12:17:09 -0700

I haven't compiled it, but doesn't this do it:

#define pbuf_clen(p, len) \
{ \
  struct pbuf *q = (p); \
  (len) = 0; \
  while (q != NULL) { \
    ++(len); \
    q = q->next; \
  }\
  len    // no semicolon!
}

-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of
Goldschmidt Simon
Sent: Wednesday, July 25, 2007 4:19 AM
To: lwip-devel
Subject: RE: [lwip-devel] [bug #3031] Implement a new fully
pool-basedpbufimplementation.

onathan,

> I think most chains will be short enough that pbuf_clen() 
> isn't much of an issue - the biggest thing would be the 
> function call overhead itself, and to be honest, pbuf_clen() 
> is so short it should probably be made a function-like macro *anyway*.

I've been breaking my head how to implement pbuf_clen as a function-like
macro, but I can't think of anything... Here's how I could solve it:

#define pbuf_clen(p, len) \
{ \
  struct pbuf *q = (p) \
  (len) = 0; \
  while (q != NULL) { \
    ++(len); \
    q = q->next; \
  }\
}

But it would change the use of pbuf_clen from 'len = pbuf_clen(p)' to
'pbuf_clen(p, len)'.
Does anybody have an idea of how to implement this as a macro so that
len
is a return value instead of an argument??

Awaiting your ideas!

Simon


_______________________________________________
lwip-devel mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-devel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]