home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************\
- ** **
- ** WW WW IIIIIIII NNN NN DDDDDDD BBBBBBB AA SSSSSS EEEEEEEE **
- ** WW W WW II NNNN NN DD DD BB BB AA AA SS EE **
- ** WW W WW II NN NN NN DD DD BBBBBBB AAAAAAAA SSSSSS EEEEEE **
- ** WW W WW II NN NNNN DD DD BB BB AA AA SS EE **
- ** WWWWW IIIIIIII NN NNN DDDDDDD BBBBBBB AA AA SSSSSS EEEEEEEE **
- ** **
- ** SSSSSS OOOOOO FFFFFFFF TTTTTTTT WW WW AA RRRRRRR EEEEEEEE **
- ** SS OO OO FF TT WW W WW AA AA RR RR EE **
- ** SSSSS OO OO FFFFF TT WW W WW AAAAAAAA RRRRRRR EEEEEE **
- ** SS OO OO FF TT WW W WW AA AA RR RR EE **
- ** SSSSSS OOOOOO FF TT WWWWW AA AA RR RR EEEEEEEE **
- ** **
- *********** NOTICE ************************************************************
- ** This file contains valuable trade secrets and proprietary **
- ** assets of Windbase Software Inc. Embodying substantial **
- ** creative efforts and confidential information. Unauthorized **
- ** use, copying, decompiling, translating, disclosure or **
- ** transfer, of any kind, is strictly prohibited. **
- ** **
- ** COPYRIGHT (C) 1992, 1993, 1994. Windbase Software Inc. **
- ** ALL RIGHTS RESERVED. **
- \*****************************************************************************/
-
- #include <stdio.h>
- #include <string.h>
- #include <malloc.h>
-
- #define WBMEMTRACE
- #include "../memsl.h"
- #include "mymal.h"
-
- #if defined(WBTRC_LEVEL1) || defined(WBTRC_LEVEL2)
- #ifdef WBSTDC
- int main(int argc, char **argv)
- #else
- int main(argc, argv)
- int argc;
- char **argv;
- #endif
- #else
- #ifdef WBSTDC
- int main(void)
- #else
- int main()
- #endif
- #endif
- {
- WBMEM *mem;
- WBERROR *errhdl;
- FILE *file;
- char str[21], *strptr[200];
- int i = 0, i2;
-
- WBTrcMainEntry();
-
- /*
- ** Set up to use user defined memory (see mymal.c)
- ** By opening a memory handle and overriding malloc()
- ** and free() with WBMallocMemH(), malloc() and free()
- ** become user defined.
- **
- ** If we want tracing, we could simply use WB_TRUE in
- ** the call to WBMemoryTracing(). Or, since tracing is
- ** the default after the WBMemoryOpen() call, we can
- ** simply omit the call to WBMemoryTracing().
- **
- ** As you can see, we can use both user defined memory
- ** and tracing at the same time.
- */
- if ((errhdl = WBErrorOpen(0,NULL)) != NULL)
- {
- if ((mem = WBMemoryOpen(errhdl,NULL,MyMalloc,NULL,MyFree)) != NULL)
- {
- /* WBMemoryTracing(mem,WB_FALSE); */
- WBMallocMemH(mem);
-
- if ((file = fopen("data.dat","r")) != NULL)
- {
- while (i < 200 && fgets(str,20,file))
- {
- if (str[strlen(str)-1] == '\n')
- str[strlen(str)-1] = 0;
-
- /*
- ** Example of user defined memory overriding
- ** malloc(). See the file mymal.c
- */
- if ((strptr[i] = malloc(strlen(str)+1)) != NULL)
- strcpy(strptr[i],str);
- i++;
- }
- fclose(file);
-
- /*
- ** Example of user defined memory overriding
- ** free(). See the file mymal.c
- **
- ** If memory tracing is on, starting at 1
- ** instead of 0 should generate one "still
- ** allocated message".
- */
- for (i2 = 1; i2 < i; i2++)
- free(strptr[i2]);
- }
- /*
- ** Tracing with user defined memory does not
- ** automaticly call the close function. Therefore,
- ** WBMemoryClose() needs to be called after all
- ** mallocs and frees.
- */
- WBMemoryClose(mem,1);
- }
- WBErrorClose(errhdl);
- }
- WBTrcReturn(0,0,("0"));
- }
-