Re: memory related concerns
- From: "Nils O. Selåsdal" <NOS@xxxxxxx>
- Date: Thu, 22 Jun 2006 10:13:19 +0200
sam_cit@xxxxxxxxxxx wrote:
Hi,
Everybody, i have a situation where i receive data in a buffer and i
read the buffer and store it in a linked list, one the problem is i can
receive any number of data... so i might run out of the memory, and the
utiltimate aim is to return the header of the linked list to the caller
of the function, so that they can process the list and do the concerned
thing.
ht list is like this
struct list
{
int date;
struct *list
};
so having seen this limitation, is there any way of work around,
where i still can return the header of the node to the caller and don't
run out of memory simultaneously.
Well, you could do lazy evaluation of the list. Read what you need
into the current node of the list. When the caller wants to process the
next node - call a function rather than just dereference node->next)
which read/generate and fills in the next link in the list and disposes the current node (incorporate instructions in the node so it knows
where to start reading from when you're processing the next node.)
Eventually this might just be a seemingly awkward way of streaming
chunks of data though :-)
.
- References:
- memory related concerns
- From: sam_cit
- memory related concerns
- Prev by Date: Re: function * = void *
- Next by Date: Re: Named parameters
- Previous by thread: memory related concerns
- Next by thread: Re: memory related concerns
- Index(es):
Relevant Pages
|