Both are beautiful. The only difference is that the previous approach will work if you try to release a myPtrsecond time.
Depending on the language you use, the string mallocmay be slightly matched.
sizeof(*myPtr) . C,
double* myPtr = malloc(sizeof(*myPtr)*5);
WhozCraig, ++,
std::vector<double> ar(5);
5 double, , , , .