You cannot free memory that has been dynamically allocated with malloc. That staed, if you have allocated previously in your program stdList->head with malloc(), freeing ptr should work fine (just remember not to reference stdList->head anymore)
You cannot free memory that has been dynamically allocated with malloc.
Did you mean
You cannot free memory that has not been dynamically allocated with malloc?
:)
Also maybe set ptr = nullptr after free, but as pointed out above, Murphy's law guarantees that someone's going to try and use stdList->head and cause an access violation.