Looks like this would not work even if it would be C++
int size=0;
char *buf2=new char[size]; //

?
this would do nothing since size if 0.
If you want to create an array use a size greater then 0 or end up with zero elements.
Arrays will not grow on their own
memcpy(buf2+size,buf1,sizeof(buf1));
size++
This 'buf2+size' will run out of your allocated space soon and cause all kinds of undetermained behaviour.
If you really want arrays to grow dynamically you should create a new one that is larger than the previous. Copy the previous in the newly created one and then delete the previous to prevent memory leak. I don't know if this will affect memory fragmentation though.
Good luck.