L'allocazione va bene. E' la deallocazione che lascia a desiderare.
P.S. Che utilità ha quel typedef char T?