[Top][All Lists]

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

[lwip-devel] New buffer management code (fwd)

From: lukem . lwip
Subject: [lwip-devel] New buffer management code (fwd)
Date: Wed, 3 Dec 2003 11:29:25 +1100 (EST)

I have been writing some buffer management code for lwIP, which replaces
the code in pbuf.c & pbuf.h.

The motivation has been to have the ability to add special pbuf types
dynamically to allow for things like handling memory which is allocated
externally to the system, and requires extra information to be attached to
the pbuf.

The way I have done this is to provide a generic pbuf structure, plus a
structure containing function pointers to perform non-generic pbuf

So I have...

struct pbuf_manager {
  struct pbuf * (*pbuf_alloc)   (u16_t offset, u16_t size,
                                 struct pbuf_manager *mgr, void *src);
  void (*pbuf_realloc)          (struct pbuf *p, u16_t size);
  void (*pbuf_free)             (struct pbuf *p);
  u8_t (*pbuf_header)           (struct pbuf *p, s16_t header_size);

struct pbuf {
  struct pbuf *next;
  void *payload;
  struct pbuf_manager *manager;
  u16_t tot_len;
  u16_t len;
  u16_t ref;

I have also changed the pbuf_alloc() function by replacing the pbuf type
with a pointer to a pbuf_manager, such that PBUF_RAM/PBUF_ROM etc. can be
#defined to these types, which minimises changes to the rest of the code
(though this should probably be removed in the long term).

struct pbuf *pbuf_alloc(u16_t offset, u16_t size,
                          struct pbuf_manager *mgr, void *src);

The other thing you will notice is the void *src parameter, which is used
to specify source data, which is given as an alternative to modifying the
pbuf payload after allocation.

The semantics of the other pbuf_* functions has not been changed.

So basically, I'm currently testing this code, and would like to
contribute it to the devel cvs tree in the near future.

To finish with a question, under this system, do we really need to have

Luke Macpherson

reply via email to

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