Re: freeing a static after one use only?

From: Peter T. Breuer (ptb@it.uc3m.es)
Date: Fri Feb 18 2000 - 08:19:58 EST


"A month of sundays ago Alan Cox wrote:"
> > the temporary structure from the stack? Either it is so, and I am about
> > to crash (the array is about 10K), or gcc has made a kmalloc/kfree
> > call ... or it has allocated the temporary data as a static constant.
>
> gcc made it static content

Interesting. Fine control of memory allocation strategies is harder to
achieve in C than it seems! In the example, I declared no statics,
and I thought that therefore the allocation of the temporary
constructor expression would come from the stack (causing me to
cringe and wait for the crash ..).

I'll repeat the code section, just to make it clear ...
     
  init_module() {
    FOO *foo;
    ....
    foo = kmalloc(lots...);
    __memcpy(foo,(FOO[]){ // use of constructor expression
                 ...
                 { 3, "holidays" },
                 ...
                 },
              many);

So, no win, no lose. I might have tried next

    foo[0] = ..;
    foo[1] = ..;
    ....

But that will expand the code section by a few hundred instructions!
Nevertheless, I'll try it.

Peter

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Feb 23 2000 - 21:00:21 EST