Does memory for localtime need to be deallocated?

后端 未结 2 1227
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-07 02:08
void log(){
    time_t current = time(0);
    tm *ptm = localtime(¤t);
        stuf...
}

Just want to be sure - do i need to release tm point

2条回答
  •  终归单人心
    2021-02-07 02:43

    No you should not deallocate it,the structure is statically allocated.

    Check the documentation:

    Return value
    pointer to a static internal std::tm object on success, or NULL otherwise. The structure may be shared between std::gmtime, std::localtime, and std::ctime, and may be overwritten on each invocation.

提交回复
热议问题