I'm having troubles understanding how realloc works. If I malloc'ed a buffer and copied data to that buffer, let's say "AB":
 +------------+
 | A | B | \0 |
 +------------+
then I realloc'ed the buffer, will there be any lost in the data (even a single byte)?; or it just does expanding the buffer? :
 +------------------------+
 | A | B | \0 | ? | ? | ? |
 +------------------------+
code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
    char* buffer    = (char*) malloc( sizeof(char) * 3 );
    strncpy(buffer, "AB", 2);
    buffer          = (char*) realloc(buffer, sizeof(char) * 6); /* Will there be any lost here? */
    free(buffer);
    return(0);
}
 
     
    