#define my_routines
#include <memory.h>
#include <string.h>
#ifdef No_BOSS
#include "mynowin.h"
#else
#include <windows.h>
#endif


   char *my_array[4000];
   int my_tester=0;



   void my_ferror(i)
   char *i;
   {
      WINDOWPTR ll;

      ll=wn_open(0,10,10,35,5,RVIDEO,RVIDEO);
      wn_titla(ll,"Memory allocation error.",NVIDEO);
      v_wtty(7);
#ifdef The_BOSS
      wn_printf(ll,"attempt to free unallocated memory at:\n ");
      wn_printf(ll," address: %p\n",(char * far)i);
      wn_printf(ll," blocks allocated: %d",my_tester);
#else
      printf("attempt to free unallocated memory at:\n ");
      printf(" address: %p\n",(char * far)i);
      printf(" blocks allocated: %d",my_tester);
#endif
      getch();
      wn_close(ll);
      }


   void my_aerror(i)
   char *i;
   {
      WINDOWPTR ll;

      ll=wn_open(0,10,10,35,5,RVIDEO,RVIDEO);
      wn_titla(ll,"Memory allocation error.",NVIDEO);
      v_wtty(7);
#ifdef The_BOSS
      wn_printf(ll,"attempt to allocate %i memory  ",i);
#else
      printf("attempt to allocate %i memory  ",i);
#endif
      getch();
      wn_close(ll);
      }



   char *my_malloc(i)
   unsigned i;
   {

      if (i){
         my_array[my_tester++]=malloc(i);
         if(my_array[my_tester-1]==NULL){
            my_aerror(i);
            my_tester--;
            return(NULL);
            }
         return(my_array[my_tester-1]);
         }
      else{
         my_aerror(i);
         return(NULL);
         }
      }


   void my_stat()
   {
      WINDOWPTR ll,hh;
      int i;

      ll=wn_open(0,10,10,45,7,RVIDEO,RVIDEO);
      wn_titla(ll,"Memory allocation status.",NVIDEO);
      if(my_tester){
#ifdef The_BOSS
         wn_printf(ll,"%d blocks of memory allocated.\n",my_tester);
         wn_printf(ll,"any char for next block. <esc> to quit.");
#else
         printf("%d blocks of memory allocated.\n",my_tester);
         printf("any char for next block. <esc> to quit.");
#endif
         hh=wn_open(1000,13,11,45,5,NVIDEO,NVIDEO);
         for (i=0;i<my_tester;i++){
#ifdef The_BOSS
            wn_printf(hh,"\n%p   %d/%d",(char far *)my_array[i],i+1,my_tester);
#else
            printf("\n%p   %d/%d",(char far *)my_array[i],i+1,my_tester);
#endif
            if(getch()==0x1b)break;
            }
         wn_close(hh);
         }
      else{
         v_wtty(7);
#ifdef The_BOSS
         wn_printf(ll,"  No blocks allocated.");
#else
         printf("  No blocks allocated.");
#endif
         getch();
         }
      wn_close(ll);
      }



   char *my_calloc(n,size)
   unsigned n;
   unsigned size;
   {
      auto char *i;
      auto int nn;

      if ((i=my_malloc(nn=(n*size)))==NULL){
         return(NULL);
         }
      else{
         memset(i,0x0000,nn);
         }
      return(i);
      }


   void my_free(i)
   char *i;
   {
      auto int j,k;
      auto int l=1;
      for(j=0;j<my_tester;j++){
         if (my_array[j]==i){
            for(k=j;k<my_tester;k++){
               my_array[k]=my_array[k+1];
               }
            my_tester--;
            l=0;
            break;
            }
         }
      if (l==1){
         my_ferror(i);
         return;
         }
      my_array[my_tester]=i;
      free(i);
      }



   char *my_realloc(i,size)
   char *i;
   unsigned size;
   {
      auto int j,k;
      auto int l=1;
      for(j=0;j<my_tester;j++){
         if (my_array[j]==i){
            return(realloc(i,size));
            }
         }
      if (i != my_array[my_tester]){
         my_ferror(i);
         return(NULL);
         }
      else {
         if (size){
            my_array[my_tester++]=realloc(i,size);
            if(my_array[my_tester-1]==NULL){
               my_aerror(size);
               my_tester--;
               return(NULL);
               }
            return(my_array[my_tester-1]);
            }
         else{
            my_aerror(size);
            return(NULL);
            }
         }
      }



