Re: Inline Assembly - Runtime Stack Allocation

From: Richard Bos (rlb_at_hoekstra-uitgeverij.nl)
Date: 07/01/04


Date: Thu, 01 Jul 2004 07:11:32 GMT

lindahlb@hotmail.com (Brian Lindahl) wrote:

> I'm using a temporary buffer to transfer some data and would rather
> not allocate it on the heap. The problem is that the size of the
> buffer is only known upon entry into the function that utilizes it and
> I'd rather not waste space or dynamically allocate on the heap (since
> it doesn't need to persist). Now I'm planning on utilizing inline
> assembly to modify the stack pointer directly to allocate the space I
> need.

This is usually a very, very bad idea. What actual reasons have you for
_not_ using malloc(), which is quite nicely suited to this task? Come to
think of it, since you're using this space only as a transfer buffer,
why can't you transfer your data in fixed-size chunks?

Richard



Relevant Pages

  • Re: memory fragmentation
    ... My application have to allocate small buffer for sending data ... I doubt the heap algorithms are O, but I also doubt they are O. ...
    (microsoft.public.vc.language)
  • Re: How to PostMessage with a string parameter?
    ... > How do I post a message with a string parameter? ... You can allocate a buffer on the heap and send the pointer cast to ...
    (microsoft.public.vc.atl)
  • Re: Runtime stack allocation
    ... I'd rather not waste space or dynamically allocate on the heap (since ... //INLINED (Intel p4 assembly) ... //do some stuff with the temporary buffer, ...
    (comp.lang.c)
  • Re: Kernel malloc/realloc?
    ... No, it can't guarantees that the memory is not moved in physical, because as ... If you alloc 4K then you grow the buffer, no coppy will be made, this is my ... Even better, on application side, you can allways allocate multiples of 4K ...
    (microsoft.public.development.device.drivers)
  • Re: Huge pages and small pages. . .
    ... >> what looks like contiguous memory and away you go. ... you need to have them cached in the TLB; if the TLB runs out of ... > low end of the heap, until someone figures out a way to tell the system ... When you allocate memory, the kernel just marks a promised ...
    (Linux-Kernel)