3 * Copyright (C) 2009 Simone Piccardi
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /****************************************************************
21 * Program checkmcheck:
22 * Some sample tests on mcheck
24 * Author: Simone Piccardi
27 * Usage: errcode -h give all info's
29 ****************************************************************/
31 * Include needed headers
33 #include <errno.h> /* error definitions and routines */
34 #include <stdlib.h> /* C standard library */
35 #include <unistd.h> /* unix standard library */
36 #include <stdio.h> /* standard I/O library */
37 #include <string.h> /* C strings library */
38 #include <mcheck.h> /* Malloc checking library */
41 void myabort(enum mcheck_status status);
42 void printcode(enum mcheck_status status);
44 int main(int argc, char *argv[])
47 * Variables definition
53 ret = mcheck(myabort);
55 printcode(mprobe(ptr));
57 printcode(mprobe(ptr));
59 printcode(mprobe(ptr));
65 void printcode(status)
69 printf("Status code = MCHECK_DISABLED\n");
72 printf("Status code = MCHECK_OK\n");
75 printf("Status code = MCHECK_HEAD\n");
78 printf("Status code = MCHECK_TAIL\n");
81 printf("Status code = MCHECK_FREE\n");
88 * routine to print code and abort
90 void myabort(enum mcheck_status status)