Re: On bit fields usage
- From: Ben Bacarisse <ben.usenet@xxxxxxxxx>
- Date: Wed, 29 Aug 2007 16:30:17 +0100
bitshadow <caroundw5h@xxxxxxxxx> writes:
On Aug 28, 6:14 pm, Ben Bacarisse <ben.use...@xxxxxxxxx> wrote:
What Keith Thompson was most likely referring to when he said "but IThanks for your reply ben and clarifying that up for me. the previous
don't think that's what you want" is that in most network code, one
puts the header and payload in one contiguous block of memory because
this (except on *very* interesting hardware) simplifies the interface
to lower-level send and receive functions.
code only sends 20bytes even aftter i've malloced and added the
payload and i was wondering where i could have possibly gone wrong. it
tells me the bit field is 20 bytes, the (char *) is four and then the
bytes sent is 20. that means somehow it seems not to be mallocing the
required amount or perhaps not adding the audio i need.
All this is rather unclear. I suspect there may be something wrong
with the code that does the allocation. Showing only struct
declarations does not give enough information.
If the error is in standard stuff like allocation and freeing,
bitfield setting and so on then it is topical here. Best would be a
short compilable example that shows something going wrong.
If the error is in the send/receive protocol stuff, you should post in
a group that discuss your platform/
Could it be then its better to hard code the size of the payload since
that will save it one contiguous block of memory: ex:
typedef struct{
rtp_hdr Header;
char audio[MAX_LEN];
}Payload;
That is often done. Whether it is "better" depends on too many things
to be answerable!
is that what you mean by putting the header and payload in one
contiguous block of memory, since if i malloc it i can't gurantee
where it will be.
Yes. The second part of that, suggests that you might be having
trouble making sure that you are send the data you want to send.
There is not problem having the data in a separate buffer, but you
would then, usually, be sending in two parts -- the header (minus the
'char *' field which is meaningless when sent) and the data pointer to by the
'char *' field.
--
Ben.
.
- Follow-Ups:
- Re: On bit fields usage
- From: bitshadow
- Re: On bit fields usage
- References:
- On bit fields usage
- From: bitshadow
- Re: On bit fields usage
- From: Keith Thompson
- Re: On bit fields usage
- From: bitshadow
- Re: On bit fields usage
- From: Ben Bacarisse
- Re: On bit fields usage
- From: bitshadow
- On bit fields usage
- Prev by Date: Re: Porting C software
- Next by Date: Re: plot
- Previous by thread: Re: On bit fields usage
- Next by thread: Re: On bit fields usage
- Index(es):
Relevant Pages
|
Loading