my question is: if I allocate memory using malloc and supposing the memory space end, when I use a subsequent malloc function can the latter overwrite the previous space ? Should an error message occurs ? How can I to avoid this issue ?
Consider this sample of c code:
double *t;    
    t = (double *)malloc(dim*sizeof(double));
    if(t == NULL)
    {
        puts("MALLOC ERROR"); 
        return 1;
    } 
double *t2;    
    t2 = (double *)malloc(dim*sizeof(double));
    if(t2 == NULL)
    {
        puts("MALLOC ERROR"); 
        return 1;
    }
how can i be sure that t2 does not overwrite the memory space of t ?
 
     
    