home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dbmalloc.zip / teststack.c < prev    next >
C/C++ Source or Header  |  1993-01-04  |  1KB  |  98 lines

  1. /*
  2.  * (c) Copyright 1990, 1991, 1992 Conor P. Cahill (cpcahil@virtech.vti.com)
  3.  *
  4.  * This software may be distributed freely as long as the following conditions
  5.  * are met:
  6.  *         * the distribution, or any derivative thereof, may not be
  7.  *          included as part of a commercial product
  8.  *        * full source code is provided including this copyright
  9.  *        * there is no charge for the software itself (there may be
  10.  *          a minimal charge for the copying or distribution effort)
  11.  *        * this copyright notice is not modified or removed from any
  12.  *          source file
  13.  */
  14.  
  15. #include "sysdefs.h"
  16. #include <stdio.h>
  17. #if ANSI_HEADERS
  18. #include <stdlib.h>
  19. #endif
  20. #include <sys/types.h>
  21. #include "malloc.h"
  22.  
  23. VOIDTYPE    sub1();
  24. VOIDTYPE    sub2();
  25. VOIDTYPE    sub3();
  26.  
  27. /*ARGSUSED*/
  28. int
  29. main(argc,argv)
  30.     int              argc;
  31.     char            **argv[];
  32. {
  33.  
  34.     char            * s;
  35.  
  36.     malloc_enter("main");
  37.  
  38.     s = malloc(10);
  39.  
  40.     sub1();
  41.     sub2();
  42.     sub3();
  43.     
  44.     malloc_leave("main");
  45.     
  46.     malloc_dump(1);
  47.  
  48.     return(0);
  49. }
  50.  
  51. VOIDTYPE
  52. sub1()
  53. {
  54.     char     * s;
  55.     malloc_enter("sub1");
  56.  
  57.     s = malloc(0);    
  58.  
  59.     sub2();
  60.  
  61.     sub3();
  62.     
  63.     sub2();
  64.  
  65.     s = malloc(10);
  66.  
  67.     malloc_leave("sub1");
  68. }
  69.  
  70. VOIDTYPE
  71. sub2()
  72. {
  73.     char     * s;
  74.     malloc_enter("sub2");
  75.  
  76.     s = malloc(0);    
  77.  
  78.     sub3();
  79.     
  80.     s = malloc(10);
  81.  
  82.     malloc_leave("sub2");
  83. }
  84.  
  85. VOIDTYPE
  86. sub3()
  87. {
  88.     char     * s;
  89.     malloc_enter("sub3");
  90.  
  91.     s = malloc(1);    
  92.  
  93.     strcpy(s,"1");
  94.  
  95.     malloc_leave("sub3");
  96. }
  97.  
  98.