Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. $ cat main.c
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. typedef struct {
  6. int id_cinta;
  7. } pmanager_t;
  8.  
  9. int main () {
  10. int i = 5, n_max_cintas = 10;
  11. pmanager_t *datos_entrada;
  12.  
  13. datos_entrada = (pmanager_t *)malloc(sizeof(pmanager_t)*(n_max_cintas));
  14. datos_entrada[i].id_cinta = 7;
  15. fprintf(stdout, "%i", datos_entrada[i].id_cinta);
  16. free(datos_entrada);
  17. return 0;
  18. }
  19. $ gcc -Wall -pedantic main.c
  20. $ valgrind ./a.out
  21. ==12727== Memcheck, a memory error detector
  22. ==12727== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
  23. ==12727== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
  24. ==12727== Command: ./a.out
  25. ==12727==
  26. 7==12727==
  27. ==12727== HEAP SUMMARY:
  28. ==12727== in use at exit: 0 bytes in 0 blocks
  29. ==12727== total heap usage: 1 allocs, 1 frees, 40 bytes allocated
  30. ==12727==
  31. ==12727== All heap blocks were freed -- no leaks are possible
  32. ==12727==
  33. ==12727== For counts of detected and suppressed errors, rerun with: -v
  34. ==12727== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement