Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. /* ************************************************************************** */
  2.  
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5.  
  6. /* ************************************************************************** */
  7.  
  8. int main(void)
  9. {
  10. char *mem_;
  11.  
  12. if (!(mem_ = (char *)malloc(sizeof(char) * 64)))
  13. {
  14. return (0); // or exit(-1) anywhere else in the code.
  15. }
  16.  
  17. ////////////////////////////////////////////////////////////////////////////
  18. // After the next instruction, the allocated memory location will be forever
  19. // lost, causing a memory leak. Comment it to avoid any leaks.
  20. ////////////////////////////////////////////////////////////////////////////
  21.  
  22. mem_ = NULL;
  23.  
  24. ////////////////////////////////////////////////////////////////////////////
  25.  
  26. while (42)
  27. {
  28. ;
  29. }
  30. return (0);
  31. }
  32.  
  33. /* ************************************************************************** */
  34. /* valgrind --leak-check=full ./a.out */
  35. /* ************************************************************************** */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement