|This is how you can write
“exception safe” code in C.
|This code is not readable—a
lot of bookkeeping. It is also incorrect. Consider what happens when an
exception is thrown between the two mallocs. The freeing of p2 will result in
unexpected behavior. Correct code should start with:
|char * p1 = 0;
|char * p2 = 0;