lkml.org 
[lkml]   [2000]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: freeing a static after one use only?
Date
"A month of sundays ago Alan Cox wrote:"
> [ptb wrote]
> > It's much larger than the thing it's used to create, so there is no
> > advantage in overwriting it with the result.
> >
> > (I imagine that some of the lowlevel sound card drivers do this, when
> > they want to load firmware).
>
> They cheat and load a file. Its ugly its bad and Linus doesnt approve of
> the sound approach.
>
> You want to sit with most of the driver uninitialised until someone opens
> it and does an ioctl load-microcode, then finish registering the devices

I have experimented with using the gcc constructor extensions. The C
ones, that is, not the asm "do at startup" .ctors stuff.

init_module() { ....

foo = kmalloc(lots...);
__memcpy(foo,(FOO[]){ // use of constructor expression
...
{ 3, "holidays" },
...
},
many);
...
use(foo);
kfree(foo); // want to get rid of foo now!!!

and to my surprise this doesn't oops. I thought this would allocate
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.

That seems likely as I see no change in the footprint of the module
code when loaded. Is only the max size returned by lsmod?

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/

\
 
 \ /
  Last update: 2005-03-22 13:56    [W:0.103 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site