Sorry that you've given up because I still don't understand. I did some tests that I posted earlier in the thread that show that there is no difference between casting and not casting when there are...
Type: Posts; User: oomakoo
Sorry that you've given up because I still don't understand. I did some tests that I posted earlier in the thread that show that there is no difference between casting and not casting when there are...
Whoops! This is why I like to use sizeof() for all my malloc()s. :-)
My point was that by casting the compiler checks the type of the memory that I *think* I'm allocating. Without the cast the...
I ran your code:
#include <stdlib.h>
int main()
{
char *p;
p=(char *)malloc(30);
if(p==NULL)
{
printf("Oops, not enought mem.");
I don't think I do. malloc() will always return a void *. If you tell the compiler what you think it should be cast to (by explicitely casting) then the compiler can tell you whether you are right...
IMHO, while not strictly necessary, casting the return from malloc() is good programming practice and should always be done - there is no reason not to do it. And getting into the habit of using...
malloc(), etc. allocate on to the heap not the stack.
there is a function alloca() that allocates on to the stack but that's not what you want is it?
I am using C and the variable in the .so is a static int.
My program calls one of the functions in the .so and initialises it to a unique value. Then control returns back to the program. Then,...
I have a program that is invoked many times simultaneously. The program uses a dynamic library. In the library there is a top level static integer that I want to have a unique value for each...