c – std :: string :: clear和std :: list :: clear清除内存中
发布时间:2020-12-16 05:38:50 所属栏目:百科 来源:网络整理
导读:在string :: clear函数的描述中,它说: clear: Erases the contents of the string,which becomes an empty string (with a length of 0 characters). 在list :: clear函数的描述中,它说: clear: Removes all elements from the list container (which are
在string :: clear函数的描述中,它说:
在list :: clear函数的描述中,它说:
清除是否覆盖字符串和列表的内存或只是释放它们? 解决方法
内存不会被覆盖.它甚至不能保证被释放.
例如,如果您创建一个巨大的字符串并调用其清除,则只会减小其大小,但仍可以保留分配的内存.但是,如果字符串超出范围,它将被释放. std :: list至少保证列表中的元素将被清除,如果你清除列表. 所以,如果你的内存包含敏感数据,你应该手动覆盖它们. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |