Skip to content

Instantly share code, notes, and snippets.

@jeremyheiler
Created April 27, 2014 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyheiler/11336482 to your computer and use it in GitHub Desktop.
Save jeremyheiler/11336482 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <readline/readline.h>
#include <readline/history.h>
int
main(int argc, char** argv)
{
puts("JL 0.0.1");
puts("Press C-c to exit\n");
//while (1) {
char *input = readline("jl> ");
add_history(input);
printf("%s\n", input);
free(input);
//}
return 0;
}
$ valgrind ./foo
==1861== Memcheck, a memory error detector
==1861== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==1861== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==1861== Command: ./foo
==1861==
JL 0.0.1
Press C-c to exit
jl>
==1861==
==1861== HEAP SUMMARY:
==1861== in use at exit: 122,013 bytes in 187 blocks
==1861== total heap usage: 2,664 allocs, 2,477 frees, 254,683 bytes allocated
==1861==
==1861== LEAK SUMMARY:
==1861== definitely lost: 0 bytes in 0 blocks
==1861== indirectly lost: 0 bytes in 0 blocks
==1861== possibly lost: 0 bytes in 0 blocks
==1861== still reachable: 122,013 bytes in 187 blocks
==1861== suppressed: 0 bytes in 0 blocks
==1861== Rerun with --leak-check=full to see details of leaked memory
==1861==
==1861== For counts of detected and suppressed errors, rerun with: -v
==1861== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment