Last active
March 24, 2018 07:38
-
-
Save wjx0912/cff38e4b6c90a29c8daaab9fe63f374b to your computer and use it in GitHub Desktop.
c++ auto delete(malloc, new...)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char *buffer = (char *)malloc(len); | |
std::shared_ptr<void> _free_ptr((void *)buffer, [](void *p){ | |
free(p); | |
}); | |
// 补充 | |
// FILE *fp = fopen("filepath", "rw"); | |
// use shared_ptr deleter do fclose(fp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment