Doing builds with debug info is a speed critical operation. While your method works, it involves a redundant malloc/copy/free operation.