Re: On bit fields usage



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 I
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.

Thanks for your reply ben and clarifying that up for me. the previous
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.
.



Relevant Pages

  • Re: On bit fields usage
    ... puts the header and payload in one contiguous block of memory because ... payload and i was wondering where i could have possibly gone wrong. ...
    (comp.lang.c)
  • Re: Problem with ASP on Webserver
    ... Entrek's TOOLBOX is a lot better for memory stuff. ... the script we sometimes ... (Accept-Language:) ...
    (microsoft.public.windowsce.platbuilder)
  • Re: NASM pe segfaults, RosAsm dissassembles the PE and runs it withoutsegfaulting
    ... Does it or does it not include .bss size? ... DWORD SizeOfImage ... which each section requires less than a page of memory. ... file's optional header, and the TimeDateStamp from the equivalent field in the PE file ...
    (alt.lang.asm)
  • Re: some questions
    ... I think you believe that the program loader loads the PE header into ... windows does infact usually load the PE header to memory. ... You can use GetModuleHandleto get your image load address (it isn't ... the program loader doesn't simply load all the bytes of a PE ...
    (alt.lang.asm)
  • Re: Dynamic Disassembler (determine main() location at runtime)
    ... Once you have the PE header, it is simple to determine the section header VA's by parsing the image header itself. ... The memory manager sets pages as executable based on the section header for a region, which describes the protection flags for that region. ... The current dead space seems to be 0x00 and 0xCC on ... Windows SDK MVPhttp://www.nynaeve.net"Jeffrey Walton" wrote in message ...
    (microsoft.public.win32.programmer.kernel)

Loading