thanks it was answered.
thanks it was answered.
Last edited by complicato; 04-20-2008 at 08:41 PM. Reason: answered.
Once something is freed (and I'm assuming this works for kfree too), it doesn't exist anymore. So you immediately destroy your filename and filedata after you copy it in. It seems unlikely that that's what you want.
Bud you can't just go around allocating memory then comparing it as if it contains useful data. That is like a commandment of programming... Thou shalt not useth uninitialized data.
Heh.. by the way, noticed how your program is behaving in an undefined way and you are practicing something that is undefined. Who would have thought
yeah i'm new to this malloc thing. I don't quite understand it. So how can i store and retrieve the data without losing it?
Look
Do you understand that ? You first allocated memory for the filename, then you copied arg2 into filename, and then you freed it right after that.f_info[i].filename = (char*) kmalloc(fn_size+1, GFP_KERNEL);
strcpy(f_info[i].filename, arg2);
kfree(f_info[i].filename);
It doesn't make any sense. So don't free it, as tabstop says.
=========================================
Everytime you segfault, you murder some part of the world
yeah i'm an idiot but i'm trying to learn. I'm really new to this malloc and not really savvy at c as you can tell :P
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
And another thing don't destroy the thread after you have an answer, it's rude and stupid.
For example, if someone had already asked the same or similar question to yours, you wouldn't have to have asked... saving everyone's time.
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.