home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume32 / dbmalloc / part03 < prev    next >
Encoding:
Text File  |  1992-09-03  |  56.5 KB  |  2,731 lines

  1. Newsgroups: comp.sources.misc
  2. From: cpcahil@vti.com (Conor P. Cahill)
  3. Subject:  v32i008:  dbmalloc - Debug Malloc Library PL14, Part03/10
  4. Message-ID: <1992Sep4.151829.12481@sparky.imd.sterling.com>
  5. X-Md4-Signature: a13bcfeaac841047b679bf9a0d8e0ed0
  6. Date: Fri, 4 Sep 1992 15:18:29 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: cpcahil@vti.com (Conor P. Cahill)
  10. Posting-number: Volume 32, Issue 8
  11. Archive-name: dbmalloc/part03
  12. Environment: C, UNIX
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then unpack
  16. # it by saving it into a file and typing "sh file".  To overwrite existing
  17. # files, type "sh file -c".  You can also feed this as standard input via
  18. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  19. # will see the following message at the end:
  20. #        "End of archive 3 (of 10)."
  21. # Contents:  calloc.c cctest.c datamc.c datams.c debug.h dgmalloc.c
  22. #   dump.c fill.c tostring.h
  23. # Wrapped by cpcahil@virtech on Thu Sep  3 18:39:18 1992
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f 'calloc.c' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'calloc.c'\"
  27. else
  28. echo shar: Extracting \"'calloc.c'\" \(4855 characters\)
  29. sed "s/^X//" >'calloc.c' <<'END_OF_FILE'
  30. X
  31. X/*
  32. X * (c) Copyright 1990, 1991, 1992 Conor P. Cahill (cpcahil@virtech.vti.com)
  33. X *
  34. X * This software may be distributed freely as long as the following conditions
  35. X * are met:
  36. X *         * the distribution, or any derivative thereof, may not be
  37. X *          included as part of a commercial product
  38. X *        * full source code is provided including this copyright
  39. X *        * there is no charge for the software itself (there may be
  40. X *          a minimal charge for the copying or distribution effort)
  41. X *        * this copyright notice is not modified or removed from any
  42. X *          source file
  43. X */
  44. X#include <stdio.h>
  45. X
  46. X#include "mallocin.h"
  47. X
  48. X#ifndef lint
  49. Xstatic char rcs_header[] = "$Id: calloc.c,v 1.17 1992/08/22 16:27:13 cpcahil Exp $";
  50. X#endif
  51. X
  52. X/*
  53. X * Function:    calloc()
  54. X *
  55. X * Purpose:    to call debug_calloc to do the allocation
  56. X *
  57. X * Arguments:    nelem    - number of elements
  58. X *        elsize    - size of each element
  59. X *
  60. X * Returns:    whatever debug_calloc returns
  61. X *
  62. X * Narrative:    call debug_calloc and return it's return
  63. X */
  64. XDATATYPE *
  65. Xcalloc(nelem,elsize)
  66. X    SIZETYPE       nelem;
  67. X    SIZETYPE      elsize;
  68. X{
  69. X    return( debug_calloc((char *)NULL,(int)-1,nelem,elsize) );
  70. X}
  71. X
  72. X/*
  73. X * Function:    debug_calloc()
  74. X *
  75. X * Purpose:    to allocate and nullify a data area
  76. X *
  77. X * Arguments:    nelem    - number of elements
  78. X *        elsize    - size of each element
  79. X *
  80. X * Returns:    NULL    - if malloc fails
  81. X *        or pointer to allocated space
  82. X *
  83. X * Narrative:    determine size of area to malloc
  84. X *        malloc area.
  85. X *        if malloc succeeds
  86. X *            fill area with nulls
  87. X *        return ptr to malloc'd region
  88. X */
  89. X
  90. XDATATYPE *
  91. Xdebug_calloc(file,line,nelem,elsize)
  92. X    CONST char    * file;
  93. X    int          line;
  94. X    SIZETYPE       nelem;
  95. X    SIZETYPE       elsize;
  96. X{
  97. X    static IDTYPE      call_counter;
  98. X
  99. X    /*
  100. X     * increment call counter
  101. X     */
  102. X    call_counter++;
  103. X
  104. X    return( DBFcalloc("calloc",M_T_CALLOC,call_counter,
  105. X               file,line,nelem,elsize) );
  106. X
  107. X}
  108. X
  109. Xchar *
  110. XDBFcalloc(func,type,call_counter,file,line,nelem,elsize)
  111. X    CONST char    * func;
  112. X    int          type;
  113. X    IDTYPE          call_counter;
  114. X    CONST char    * file;
  115. X    int          line;
  116. X    SIZETYPE       nelem;
  117. X    SIZETYPE       elsize;
  118. X{
  119. X    DATATYPE    * ptr;
  120. X    SIZETYPE      size;
  121. X
  122. X    /*
  123. X     * make sure malloc sub-system is initialized.
  124. X     */
  125. X    MALLOC_INIT();
  126. X
  127. X    /*
  128. X     * calculate the size to allocate
  129. X     */
  130. X    size = elsize * nelem;
  131. X
  132. X    /*
  133. X     * if the user wants to be warned about zero length mallocs, do so
  134. X     */
  135. X    if( ((malloc_opts & MOPT_ZERO) != 0) && (size == 0) )
  136. X    {
  137. X        malloc_errno = M_CODE_ZERO_ALLOC;
  138. X        malloc_warning(func,file,line,(struct mlist *) NULL);
  139. X    }
  140. X
  141. X    ptr = DBFmalloc(func,type,call_counter,file,line,size);
  142. X
  143. X    if( ptr != NULL )
  144. X    {
  145. X        /*
  146. X         * clear the area that was allocated
  147. X         */
  148. X        VOIDCAST memset(ptr,'\0',size);
  149. X    }
  150. X
  151. X    return(ptr);
  152. X
  153. X} /* DBFcalloc(... */
  154. X
  155. X/*
  156. X * Function:    cfree()
  157. X *
  158. X * Purpose:    to free an area allocated by calloc (actually frees any
  159. X *        allocated area)
  160. X *
  161. X * Arguments:    cptr    - pointer to area to be freed
  162. X *
  163. X * Returns:    nothing of any use
  164. X *
  165. X * Narrative:    just call the appropriate function to perform the free
  166. X *
  167. X * Note:    most systems do not have such a call, but for the few that do,
  168. X *        it is here.
  169. X */
  170. XFREETYPE
  171. Xcfree( cptr )
  172. X    DATATYPE    * cptr;
  173. X{
  174. X    debug_cfree((CONST char *)NULL,(int)-1, cptr);
  175. X}
  176. X
  177. XFREETYPE
  178. Xdebug_cfree(file,line,cptr)
  179. X    CONST char    * file;
  180. X    int          line;
  181. X    DATATYPE    * cptr;
  182. X{
  183. X    static IDTYPE      call_counter;
  184. X
  185. X    call_counter++;    
  186. X
  187. X    DBFfree("cfree",F_T_CFREE,call_counter,file,line,cptr);
  188. X}
  189. X
  190. X/*
  191. X * $Log: calloc.c,v $
  192. X * Revision 1.17  1992/08/22  16:27:13  cpcahil
  193. X * final changes for pl14
  194. X *
  195. X * Revision 1.16  1992/07/12  15:30:58  cpcahil
  196. X * Merged in Jonathan I Kamens' changes
  197. X *
  198. X * Revision 1.15  1992/07/03  00:03:25  cpcahil
  199. X * more fixes for pl13, several suggestons from Rich Salz.
  200. X *
  201. X * Revision 1.14  1992/04/22  18:17:32  cpcahil
  202. X * added support for Xt Alloc functions, linted code
  203. X *
  204. X * Revision 1.13  1992/04/13  03:06:33  cpcahil
  205. X * Added Stack support, marking of non-leaks, auto-config, auto-testing
  206. X *
  207. X * Revision 1.12  1992/01/30  12:23:06  cpcahil
  208. X * renamed mallocint.h -> mallocin.h
  209. X *
  210. X * Revision 1.11  1992/01/10  17:28:03  cpcahil
  211. X * Added support for overriding void datatype
  212. X *
  213. X * Revision 1.10  1991/12/06  17:58:42  cpcahil
  214. X * added cfree() for compatibility with some wierd systems
  215. X *
  216. X * Revision 1.9  91/12/02  19:10:08  cpcahil
  217. X * changes for patch release 5
  218. X * 
  219. X * Revision 1.8  91/11/25  14:41:51  cpcahil
  220. X * Final changes in preparation for patch 4 release
  221. X * 
  222. X * Revision 1.7  91/11/24  00:49:21  cpcahil
  223. X * first cut at patch 4
  224. X * 
  225. X * Revision 1.6  90/05/11  00:13:07  cpcahil
  226. X * added copyright statment
  227. X * 
  228. X * Revision 1.5  90/02/24  20:41:57  cpcahil
  229. X * lint changes.
  230. X * 
  231. X * Revision 1.4  90/02/24  17:25:47  cpcahil
  232. X * changed $header to $id so full path isn't included.
  233. X * 
  234. X * Revision 1.3  90/02/24  13:32:24  cpcahil
  235. X * added function header.  moved log to end of file.
  236. X * 
  237. X * Revision 1.2  90/02/22  23:08:26  cpcahil
  238. X * fixed rcs_header line
  239. X * 
  240. X * Revision 1.1  90/02/22  23:07:38  cpcahil
  241. X * Initial revision
  242. X * 
  243. X */
  244. END_OF_FILE
  245. if test 4855 -ne `wc -c <'calloc.c'`; then
  246.     echo shar: \"'calloc.c'\" unpacked with wrong size!
  247. fi
  248. # end of 'calloc.c'
  249. fi
  250. if test -f 'cctest.c' -a "${1}" != "-c" ; then 
  251.   echo shar: Will not clobber existing file \"'cctest.c'\"
  252. else
  253. echo shar: Extracting \"'cctest.c'\" \(10577 characters\)
  254. sed "s/^X//" >'cctest.c' <<'END_OF_FILE'
  255. X/*
  256. X * (c) Copyright 1990, 1991, 1992 Conor P. Cahill (cpcahil@virtech.vti.com)
  257. X *
  258. X * This software may be distributed freely as long as the following conditions
  259. X * are met:
  260. X *         * the distribution, or any derivative thereof, may not be
  261. X *          included as part of a commercial product
  262. X *        * full source code is provided including this copyright
  263. X *        * there is no charge for the software itself (there may be
  264. X *          a minimal charge for the copying or distribution effort)
  265. X *        * this copyright notice is not modified or removed from any
  266. X *          source file
  267. X */
  268. X#if __STDC__ || __cplusplus
  269. X# define __stdcargs(s) s
  270. X#else
  271. X# define __stdcargs(s) ()
  272. X#endif
  273. X
  274. X#ifdef USE_STDLIB
  275. X#include <stdlib.h>
  276. X#endif
  277. X#ifdef USE_UNISTD
  278. X#include <unistd.h>
  279. X#endif
  280. X#ifdef USE_MALLOC
  281. X#include <malloc.h>
  282. X#endif
  283. X#ifdef USE_MEMORY_H
  284. X#include <memory.h>
  285. X#endif
  286. X#ifdef USE_STRING_H
  287. X#include <string.h>
  288. X#endif
  289. X#ifdef USE_SYSENT
  290. X#include <sysent.h>
  291. X#endif
  292. X
  293. X
  294. X/*
  295. X * $Id: cctest.c,v 1.12 1992/08/22 16:27:13 cpcahil Exp $
  296. X */
  297. X/*
  298. X * This file is not a real source file for the malloc library.  The
  299. X * configuration utility uses this file to test the various compiler
  300. X * settings that can be used by the library.
  301. X */
  302. X
  303. X#ifdef VOIDTEST
  304. X    /*
  305. X     * testing to see if the void datatype is used by this system
  306. X     */
  307. X    void *
  308. X    function()
  309. X    {
  310. X        static void * t;
  311. X
  312. X        return(t);
  313. X    }
  314. X#endif
  315. X
  316. X#ifdef EXITTEST
  317. X
  318. X/*
  319. X * determine the return type of exit
  320. X */
  321. X#if __cplusplus
  322. X    extern "C" {
  323. X#endif
  324. X        EXITTYPE exit __stdcargs((int));
  325. X#if __cplusplus
  326. X    }
  327. X#endif
  328. X#if __cplusplus || __STDC__
  329. X#include <stdio.h>
  330. Xmain(int argc, char *argv[])
  331. X#else
  332. Xmain(argc,argv)
  333. X    int      argc;
  334. X    char    * argv[];
  335. X#endif
  336. X{
  337. X
  338. X    /*
  339. X     * this bogus stuff is here simply to get c++ to shut-up about
  340. X      * unreferenced parameters.
  341. X     */
  342. X    if( argv[argc] == "hello" )
  343. X    {
  344. X        printf("hello\n");
  345. X    }
  346. X    return(0);
  347. X}
  348. X#endif /* EXITTEST */
  349. X
  350. X#ifdef SETENVTEST
  351. X/*
  352. X * determine if setenv is supported
  353. X */
  354. X#if __cplusplus || __STDC__
  355. X#include <stdio.h>
  356. Xmain(int argc, char *argv[])
  357. X#else
  358. Xmain(argc,argv)
  359. X    int      argc;
  360. X    char    * argv[];
  361. X#endif
  362. X{
  363. X#ifdef setenv
  364. X#undef setenv
  365. X#endif
  366. X
  367. X    setenv("TESTSYM","YES",1);
  368. X
  369. X    /*
  370. X     * this bogus stuff is here simply to get c++ to shut-up about
  371. X      * unreferenced parameters.
  372. X     */
  373. X    if( argv[argc] == "hello" )
  374. X    {
  375. X        printf("hello\n");
  376. X    }
  377. X    return(0);
  378. X}
  379. X#endif /* SETENVTEST */
  380. X
  381. X#ifdef MALLOCHTEST
  382. X#include <malloc.h>
  383. X#endif
  384. X#ifdef ANSIHEADERTEST
  385. X#include <stdlib.h>
  386. X#endif
  387. X#ifdef POSIXHEADERTEST
  388. X#include <unistd.h>
  389. X#endif
  390. X
  391. X#if defined(MALLOCHTEST) || defined(ANSIHEADERTEST) || defined(POSIXHEADERTEST)
  392. X/*
  393. X * determine if certain headers are available
  394. X */
  395. X#if __cplusplus || __STDC__
  396. Xmain(int argc, char *argv[])
  397. X#else
  398. Xmain(argc,argv)
  399. X    int      argc;
  400. X    char    * argv[];
  401. X#endif
  402. X{
  403. X    /*
  404. X     * this bogus stuff is here simply to get c++ to shut-up about
  405. X      * unreferenced parameters.
  406. X     */
  407. X    if( argv[argc] == "hello" )
  408. X    {
  409. X        printf("hello\n");
  410. X    }
  411. X    return(0);
  412. X}
  413. X#endif /* MALLOCHTEST || ANSIHEADERTEST || POSIXHEADERTEST */
  414. X
  415. X#ifdef ASM_UNDTEST
  416. X/*
  417. X * test requirement for underscores in external symbols
  418. X */
  419. X#if __cplusplus || __STDC__
  420. X#include <stdio.h>
  421. Xmain(int argc, char *argv[])
  422. X#else
  423. Xmain(argc,argv)
  424. X    int      argc;
  425. X    char    * argv[];
  426. X#endif
  427. X{
  428. X    int      myroutine();
  429. X
  430. X#if i386
  431. X    printf("OK\n", myroutine());
  432. X#else
  433. X    printf("NOT OK\n");
  434. X#endif
  435. X
  436. X}
  437. X
  438. X#ifdef i386
  439. X    asm("    .globl _myroutine");
  440. X    asm("_myroutine:");
  441. X    asm("    xor %eax");
  442. X    asm("   ret");
  443. X#endif
  444. X
  445. X
  446. X#endif /* ASM_UNDTEST */
  447. X
  448. X
  449. X#ifdef ASM_REPTEST
  450. X/*
  451. X * test requirement for underscores in external symbols
  452. X */
  453. X#if __cplusplus || __STDC__
  454. X#include <stdio.h>
  455. Xmain(int argc, char *argv[])
  456. X#else
  457. Xmain(argc,argv)
  458. X    int      argc;
  459. X    char    * argv[];
  460. X#endif
  461. X{
  462. X    int      myroutine();
  463. X
  464. X#if i386
  465. X    printf("OK\n", myroutine());
  466. X#else
  467. X    printf("NOT OK\n");
  468. X#endif
  469. X
  470. X}
  471. X
  472. X#ifdef i386
  473. X#ifdef USE_UNDERSCORE
  474. X    asm("    .globl _myroutine");
  475. X    asm("_myroutine:");
  476. X#else
  477. X    asm("    .globl myroutine");
  478. X    asm("myroutine:");
  479. X#endif
  480. X    asm("    xor %ecx");
  481. X    asm("    repe");
  482. X    asm("   ret");
  483. X#endif
  484. X
  485. X
  486. X#endif /* ASM_REPTEST */
  487. X
  488. X#ifdef CONSTTEST
  489. X    /*
  490. X     * testing to see if the void datatype is used by this system
  491. X     */
  492. X    const char *
  493. X    function()
  494. X    {
  495. X        static const char t[] = "hello";
  496. X
  497. X        return(t);
  498. X    }
  499. X#endif
  500. X
  501. X#ifdef MALLOC_COMPILETEST
  502. X
  503. X#if __cplusplus
  504. XDATATYPE * malloc( SIZETYPE size)
  505. X#else
  506. XDATATYPE *
  507. Xmalloc( size)
  508. X    SIZETYPE     size;
  509. X#endif
  510. X{
  511. X    if( size > 0 )
  512. X    {
  513. X        return(0);
  514. X    }
  515. X    
  516. X    return(0);
  517. X}
  518. X
  519. X#endif /* MALLOC_COMPILETEST */
  520. X
  521. X#ifdef FREE_COMPILETEST
  522. X
  523. X#if __cplusplus
  524. XFREETYPE free( DATATYPE *data)
  525. X#else
  526. XFREETYPE
  527. Xfree(data)
  528. X    DATATYPE *data;
  529. X#endif
  530. X{
  531. X    if( ! data )
  532. X    {
  533. X        printf("foo\n");
  534. X    }
  535. X}
  536. X
  537. X#endif /* FREE_COMPILETEST */
  538. X
  539. X#ifdef MEM_COMPILETEST
  540. X
  541. XMEMDATA *memcpy __stdcargs((MEMDATA *ptr1, CONST MEMDATA *ptr2, register MEMSIZE len));
  542. X
  543. X#if __cplusplus
  544. XMEMDATA * memccpy(
  545. X    MEMDATA        * ptr1,
  546. X    CONST MEMDATA    * ptr2,
  547. X    int          ch,
  548. X    MEMSIZE          len )
  549. X#else
  550. XMEMDATA *
  551. Xmemccpy(ptr1,ptr2,ch,len)
  552. X    MEMDATA        * ptr1;
  553. X    CONST MEMDATA    * ptr2;
  554. X    int          ch;
  555. X    MEMSIZE          len;
  556. X#endif
  557. X{
  558. X    /*
  559. X     * just make use of all the passed arguments so that we don't get bogus
  560. X     * warning messages about unused arguments.  What we do doesn't have
  561. X     * to make sense since we aren't going to run this.
  562. X     */
  563. X    if( (ptr1 == ptr2) && (ch != len) )
  564. X    {
  565. X        return(ptr1);
  566. X    }
  567. X    return(memcpy(ptr1,ptr2,len));
  568. X}
  569. X
  570. X#endif /* MEM_COMPILETEST */
  571. X
  572. X#ifdef STR_COMPILETEST
  573. X
  574. X#include <string.h>
  575. X#if __cplusplus
  576. XSTRSIZE strlen( CONST char * str1 )
  577. X#else
  578. XSTRSIZE
  579. Xstrlen(str1)
  580. X    CONST char * str1;
  581. X#endif
  582. X{
  583. X    if( str1[0] != '\0')
  584. X    {
  585. X        return(1);
  586. X    }
  587. X    return(0);
  588. X}
  589. X
  590. X#endif /* STR_COMPILETEST */
  591. X
  592. X#ifdef WRT_COMPILETEST
  593. X#if __cplusplus
  594. Xint write(int fd, CONST char * buf, WRTSIZE size)
  595. X#else
  596. Xint
  597. Xwrite(fd,buf,size)
  598. X     int          fd;
  599. X     CONST char    * buf;
  600. X     WRTSIZE      size;
  601. X#endif
  602. X{
  603. X    if( buf[fd] == (CONST char) size)
  604. X    {
  605. X        return(1);
  606. X    }
  607. X    return(0);
  608. X}
  609. X
  610. X#endif /* WRT_COMPILETEST */
  611. X
  612. X
  613. X#ifdef PRE_DEFINES
  614. X
  615. X/*
  616. X * this is used by the Configure script to get the compiler pre-defined symbol
  617. X * for this
  618. X */
  619. X#if __cplusplus
  620. X#include <stdio.h>
  621. Xmain(int argc, char *argv[])
  622. X#else
  623. Xmain(argc,argv)
  624. X    int      argc;
  625. X    char    * argv[];
  626. X#endif
  627. X{
  628. X    int      varcnt = 0;
  629. X
  630. X#if __GNUC__
  631. X    if (__GNUC__ > 1)
  632. X        printf("(__GNUC__ == %d)", __GNUC__);
  633. X    else
  634. X        printf("__GNUC__");
  635. X    varcnt++;
  636. X#endif
  637. X#if __STDC__ 
  638. X    if( varcnt > 0 )
  639. X    {
  640. X        printf(" && ");
  641. X    }
  642. X    printf("__STDC__");
  643. X    varcnt++;
  644. X#endif
  645. X#if __HIGHC__ 
  646. X    if( varcnt > 0 )
  647. X    {
  648. X        printf(" && ");
  649. X    }
  650. X    printf("__HIGHC__");
  651. X    varcnt++;
  652. X#endif
  653. X#if __C89__ 
  654. X    if( varcnt > 0 )
  655. X    {
  656. X        printf(" && ");
  657. X    }
  658. X    printf("__C89__");
  659. X    varcnt++;
  660. X#endif
  661. X#if __cplusplus
  662. X    if( varcnt > 0 )
  663. X    {
  664. X        printf(" && ");
  665. X    }
  666. X    /*
  667. X     * this bogus stuff is here simply to get c++ to shut-up about
  668. X      * unreferenced parameters.
  669. X     */
  670. X    if( argv[argc] == "hello" )
  671. X    {
  672. X        printf("hello\n");
  673. X    }
  674. X    printf("__cplusplus");
  675. X    varcnt++;
  676. X#endif
  677. X
  678. X    /*
  679. X     * if we found no pre-defines, print out the word none, so we can tell the
  680. X     * difference between compilation failures and no pre-defs.
  681. X     */
  682. X    if( varcnt == 0 )
  683. X    {
  684. X        printf("none");
  685. X        varcnt++;
  686. X    }
  687. X
  688. X    if( varcnt > 0 )
  689. X    {
  690. X        printf("\n");
  691. X    }
  692. X    return(0);
  693. X}
  694. X
  695. X#endif /* PRE_DEFINES */
  696. X    
  697. X
  698. X#ifdef SIGIOTTEST
  699. X#include <sys/types.h>
  700. X#include <signal.h>
  701. X    int
  702. X    function()
  703. X    {
  704. X        int signal = SIGIOT;
  705. X        return(signal);
  706. X    }
  707. X#endif
  708. X#ifdef SIGABRTTEST
  709. X#include <sys/types.h>
  710. X#include <signal.h>
  711. X    int
  712. X    function()
  713. X    {
  714. X        int signal = SIGABRT;
  715. X        return(signal);
  716. X    }
  717. X#endif
  718. X
  719. X#ifdef CHANGESTR
  720. X
  721. X#include <stdio.h>
  722. X
  723. X#define FILEBUFSIZE    (50*1024)
  724. X
  725. Xchar iobuffer[FILEBUFSIZE];
  726. X
  727. Xmain(argc,argv)
  728. X    int          argc;
  729. X    char        * argv[];
  730. X{
  731. X    unsigned int      cnt;
  732. X    FILE        * fp;
  733. X    unsigned int      i;
  734. X    int          len;
  735. X    char        * src;
  736. X    char        * tgt;
  737. X
  738. X    if( argc != 4 )
  739. X    {
  740. X        fprintf(stderr,"Usage: changestr file oldstr newstr\n");
  741. X        exit(1);
  742. X    }
  743. X    src = argv[2];
  744. X    tgt = argv[3];
  745. X
  746. X    /*
  747. X     * get length of strings (note that we don't ensure that both strings
  748. X     * are the same length and
  749. X     */
  750. X    len = strlen(src);
  751. X    i   = strlen(tgt);
  752. X    if( i > len )
  753. X    {
  754. X        fprintf(stderr,"Error: second string cannot be longer %s\n",
  755. X                "than first string");
  756. X        exit(2);
  757. X    }
  758. X
  759. X    fp = fopen(argv[1],"r+");
  760. X
  761. X    if( fp == NULL )
  762. X    {
  763. X        fprintf(stderr,"Can't open %s\n",argv[1]);
  764. X        exit(3);
  765. X    }
  766. X
  767. X    /*
  768. X     * read the entire file in (note that if the file is bigger
  769. X     * than the specified blocksize, we won't be able to
  770. X     * process it.
  771. X     */
  772. X
  773. X    cnt = fread(iobuffer,1,FILEBUFSIZE,fp);
  774. X    if( cnt <= 0 )
  775. X    {
  776. X        fprintf(stderr,"Read error when reading %s\n",argv[1]);
  777. X        exit(4);
  778. X    }
  779. X
  780. X    for(i=0; i < (cnt-len); i++)
  781. X    {
  782. X        if( memcmp(iobuffer+i,src,len) == 0 )
  783. X        {
  784. X            memcpy(iobuffer+i,tgt,len);
  785. X            i += len-1;
  786. X        }
  787. X    }
  788. X
  789. X    if( fseek(fp,0L,0) != 0 )
  790. X    {
  791. X        fprintf(stderr,"Failed to seek to correct location\n");
  792. X        exit(5);
  793. X    }
  794. X
  795. X    if( fwrite(iobuffer,1,cnt,fp) != cnt )
  796. X    {
  797. X        fprintf(stderr,"Failed to write new data\n");
  798. X        exit(6);
  799. X    }
  800. X
  801. X    fclose(fp);
  802. X    
  803. X    exit(0);
  804. X} 
  805. X
  806. X
  807. X#endif /* CHNAGESTR */
  808. X
  809. X
  810. X#ifdef TESTDATAMC
  811. X
  812. X#include <stdio.h>
  813. X
  814. Xmain(argc,argv)
  815. X    int          argc;
  816. X    char        * argv[];
  817. X{
  818. X    char          buffer[30];
  819. X
  820. X    buffer[0] = '\0';
  821. X    buffer[1] = '\0';
  822. X    buffer[2] = '\0';
  823. X    buffer[3] = '\0';
  824. X    buffer[4] = '\0';
  825. X    buffer[5] = '\0';
  826. X    buffer[6] = '\0';
  827. X    buffer[7] = '\0';
  828. X    buffer[8] = '\0';
  829. X
  830. X    DataMC(buffer, "   y",5);
  831. X    DataMC(buffer+4, "yy",3);
  832. X
  833. X    DataMC(buffer+1, buffer,7);
  834. X    DataMC(buffer,   "x",1);
  835. X
  836. X    printf("%s\n",buffer);
  837. X
  838. X    return(0);
  839. X}
  840. X
  841. X/*
  842. X * we need to have our own memcpy here in order to find out if there will be
  843. X * some problem where the kludged version of memcpy (now should be named 
  844. X * DataMC) at least one system (SGI) has gotten into an infinite loop
  845. X * when the modified DataMC ended up calling the library's memcpy
  846. X */
  847. Xmemcpy()
  848. X{
  849. X    write(1,"Infinite loop\n",14);
  850. X    exit(1);
  851. X}
  852. X
  853. X#endif /* TESTDATAMC */
  854. X
  855. X#ifdef TESTDATAMS
  856. X#include <stdio.h>
  857. X
  858. Xmain(argc,argv)
  859. X    int          argc;
  860. X    char        * argv[];
  861. X{
  862. X    char          buffer[30];
  863. X
  864. X    buffer[0] = '\0';
  865. X    buffer[1] = '\0';
  866. X    buffer[2] = '\0';
  867. X    buffer[3] = '\0';
  868. X    buffer[4] = '\0';
  869. X    buffer[5] = '\0';
  870. X    buffer[6] = '\0';
  871. X    buffer[7] = '\0';
  872. X    buffer[8] = '\0';
  873. X    buffer[9] = '\0';
  874. X    buffer[10] = '\0';
  875. X
  876. X    DataMS(buffer,  'x',1);
  877. X    DataMS(buffer+1,' ',3);
  878. X    DataMS(buffer+4,'y',3);
  879. X
  880. X    printf("%s\n",buffer);
  881. X}
  882. X
  883. Xmemset()
  884. X{
  885. X    write(1,"Infinite loop\n",14);
  886. X    exit(1);
  887. X}
  888. X
  889. X#endif /* TESTDATAMS */
  890. X
  891. X#ifdef COMPARETEST 
  892. X
  893. X#include <stdio.h>
  894. X#include <string.h>
  895. X
  896. X#if __cplusplus
  897. X#include <stdlib.h>
  898. Xmain(int argc, char *argv[])
  899. X#else
  900. Xmain(argc,argv)
  901. X    int      argc;
  902. X    char    * argv[];
  903. X#endif
  904. X{
  905. X    char          buffer[10];
  906. X    char          buf2[10];
  907. X    int          result;
  908. X
  909. X    buffer[0] = 'a';
  910. X    buffer[1] = '\0';
  911. X    buf2[0]   = 0xff;
  912. X    buf2[1] = '\0';
  913. X
  914. X    /*
  915. X     * just to get c++ and some ANSI C compilers to shutup.  argc will
  916. X     * be more than 1 when running this test.
  917. X     */
  918. X    if( argc > 10 )
  919. X    {
  920. X        result = strcmp(argv[0],"junkstr");
  921. X    }
  922. X    else
  923. X    {
  924. X        result = COMPARETEST (buffer,buf2,1);
  925. X    }
  926. X
  927. X#ifdef TESTCHAR
  928. X    result = -result;
  929. X#endif
  930. X
  931. X    if( result < 0 )
  932. X    {
  933. X        exit(0);
  934. X    }
  935. X    else
  936. X    {
  937. X        exit(1);
  938. X    }
  939. X
  940. X}
  941. X    
  942. X
  943. X#endif /* COMPARETEST */
  944. END_OF_FILE
  945. if test 10577 -ne `wc -c <'cctest.c'`; then
  946.     echo shar: \"'cctest.c'\" unpacked with wrong size!
  947. fi
  948. # end of 'cctest.c'
  949. fi
  950. if test -f 'datamc.c' -a "${1}" != "-c" ; then 
  951.   echo shar: Will not clobber existing file \"'datamc.c'\"
  952. else
  953. echo shar: Extracting \"'datamc.c'\" \(6395 characters\)
  954. sed "s/^X//" >'datamc.c' <<'END_OF_FILE'
  955. X
  956. X/*
  957. X * (c) Copyright 1990, 1991, 1992 Conor P. Cahill (cpcahil@virtech.vti.com)
  958. X *
  959. X * This software may be distributed freely as long as the following conditions
  960. X * are met:
  961. X *         * the distribution, or any derivative thereof, may not be
  962. X *          included as part of a commercial product
  963. X *        * full source code is provided including this copyright
  964. X *        * there is no charge for the software itself (there may be
  965. X *          a minimal charge for the copying or distribution effort)
  966. X *        * this copyright notice is not modified or removed from any
  967. X *          source file
  968. X */
  969. X
  970. X/*
  971. X * datamc.c - this module contains functions designed to efficiently 
  972. X *          copy memory areas in a portable fasion
  973. X *
  974. X * The configure script will usually override this module with a copy
  975. X * of the system suplied memcpy() utility if it can figure out how to
  976. X * convert the module name to DataMS.
  977. X */
  978. X#ifndef lint
  979. Xstatic
  980. Xchar rcs_hdr[] = "$Id: datamc.c,v 1.7 1992/08/22 16:27:13 cpcahil Exp $";
  981. X#endif
  982. X
  983. X#include <stdio.h>
  984. X#include "mallocin.h"
  985. X
  986. Xtypedef int word;
  987. X
  988. X#define wordmask (sizeof(word)-1)
  989. X
  990. X#ifndef DONT_USE_ASM
  991. X#ifdef i386
  992. X#define ASM_MEMCPY    1
  993. X
  994. X/*
  995. X * DataMemcpy() - asm version of memcpy for use on 386 architecture systems.
  996. X *          This is much faster than performing the operation directly.
  997. X *          Note that the operation is performed by the use of word
  998. X *          moves followed by byte moves and it doesn't matter that
  999. X *          the word moves are not on a word aligned offset.
  1000. X *
  1001. X * This function differs from the system memcpy in that it correcly handles
  1002. X * overlapping memory regions.  This is a requirement here because this is
  1003. X * the same function that is called from memmove, memcpy, and bcopy.
  1004. X */
  1005. X/*
  1006. X * DataMemcpy(tgt,src,len)
  1007. X */
  1008. X    asm("    .text");
  1009. X    asm("    .align 4");
  1010. X#ifdef USE_UNDERSCORE
  1011. X    asm("    .globl _DataMC");
  1012. X    asm("_DataMC:");
  1013. X#else
  1014. X    asm("    .globl DataMC");
  1015. X    asm("DataMC:");
  1016. X#endif
  1017. X    asm("    pushl  %edi");
  1018. X    asm("    pushl  %esi");
  1019. X    asm("    pushl  %ebx");
  1020. X
  1021. X    /*
  1022. X     * get tgt -> edi
  1023. X     *     src -> esi
  1024. X     *     len -> ecx
  1025. X     */
  1026. X    asm("    movl   16(%esp),%edi");
  1027. X    asm("    movl   20(%esp),%esi");
  1028. X    asm("    movl   24(%esp),%ecx");
  1029. X
  1030. X    /*
  1031. X     * compare target to src
  1032. X     */
  1033. X     asm("    cmpl   %edi,%esi");
  1034. X    /*
  1035. X     * if( tgt == src ) nothing to do, so return
  1036. X     */
  1037. X    asm("   je     .memdone"); 
  1038. X    /*
  1039. X     * if(    (tgt > src)
  1040. X     */
  1041. X    asm("    jg     .movenorm");
  1042. X    /*
  1043. X     *     &&  tgt < (src + len)
  1044. X     */
  1045. X    asm("    movl    %esi,%eax");
  1046. X    asm("    addl    %ecx,%eax");
  1047. X    asm("    cmpl    %edi,%eax");
  1048. X    asm("   jl    .movenorm");
  1049. X
  1050. X    /*
  1051. X     * {
  1052. X     */
  1053. X        /*
  1054. X         * move the pointers to the end of the data area to be 
  1055. X         * moved and set the direction flag so that 
  1056. X         */
  1057. X
  1058. X        /*
  1059. X         *     && ( len >= 4 ) )
  1060. X         */
  1061. X        asm("    cmpl    $4,%ecx");
  1062. X        asm("    jl    .moveshort");
  1063. X        /*
  1064. X         * {
  1065. X         */
  1066. X
  1067. X            asm("    addl    %ecx,%edi");
  1068. X            asm("    subl    $4,%edi");
  1069. X            asm("    addl    %ecx,%esi");
  1070. X            asm("    subl    $4,%esi");
  1071. X            asm("    xor    %ebx,%ebx");
  1072. X            asm("    jmp    .moveback");
  1073. X        /* 
  1074. X          * }
  1075. X         * else
  1076. X         * {
  1077. X          */
  1078. X            asm("    addl    %ecx,%edi");
  1079. X            asm("    addl    %ecx,%esi");
  1080. X            asm(".moveshort:");
  1081. X            asm("    movl    $1,%ebx");
  1082. X        /* 
  1083. X         * }
  1084. X          */
  1085. X        asm(".moveback:");
  1086. X        asm("    std");
  1087. X        asm("    jmp    .movedata");
  1088. X    /*
  1089. X     * }
  1090. X     * else
  1091. X     * {
  1092. X      */
  1093. X        asm(".movenorm:");
  1094. X        asm("    mov    $1,%ebx");
  1095. X
  1096. X    /*
  1097. X     * }
  1098. X     */
  1099. X
  1100. X    /*
  1101. X     * now go move the data
  1102. X     */
  1103. X    asm(".movedata:");
  1104. X    asm("    movl   %edi,%eax");
  1105. X    asm("    movl   %ecx,%edx");
  1106. X    asm("    shrl   $02,%ecx");
  1107. X#ifdef USE_REPE
  1108. X    asm("    repe");
  1109. X#else
  1110. X    asm("    repz");
  1111. X#endif
  1112. X    asm("    movsl ");
  1113. X
  1114. X    /*
  1115. X     * if we were performing a negative move, adjust the pointer
  1116. X     * so that it points to the previous byte (right now it points
  1117. X      * to the previous word
  1118. X     */
  1119. X    asm("    cmpl    $0,%ebx");
  1120. X    asm("   jnz    .movedata2");
  1121. X    /*
  1122. X     * {
  1123. X     */
  1124. X        asm("    addl    $3,%edi");
  1125. X        asm("    addl    $3,%esi");
  1126. X    /* 
  1127. X     * }
  1128. X     */
  1129. X
  1130. X    asm(".movedata2:");    
  1131. X    asm("    movl   %edx,%ecx");
  1132. X    asm("    andl   $03,%ecx");
  1133. X#ifdef USE_REPE
  1134. X    asm("    repe");
  1135. X#else
  1136. X    asm("    repz");
  1137. X#endif
  1138. X    asm("    movsb ");
  1139. X
  1140. X    asm("    cld");
  1141. X
  1142. X    /*
  1143. X     * return
  1144. X     */
  1145. X    asm(".memdone:");
  1146. X    asm("    popl    %ebx");
  1147. X    asm("    popl    %esi");
  1148. X    asm("    popl    %edi");
  1149. X    asm("    ret");
  1150. X
  1151. X
  1152. X#endif /* i386 */
  1153. X#endif /* DONT_USE_ASM */
  1154. X
  1155. X#ifndef ASM_MEMCPY
  1156. X
  1157. Xvoid
  1158. XDataMC(ptr1,ptr2,len)
  1159. X    MEMDATA            * ptr1;
  1160. X    CONST MEMDATA        * ptr2;
  1161. X    MEMSIZE              len;
  1162. X{
  1163. X    register MEMSIZE      i;
  1164. X    register char        * myptr1;
  1165. X    register CONST char    * myptr2;
  1166. X
  1167. X    if( len <= 0 )
  1168. X    {
  1169. X        return;
  1170. X    }
  1171. X
  1172. X    myptr1 = ptr1;
  1173. X    myptr2 = ptr2;
  1174. X
  1175. X    /*
  1176. X     * while the normal memcpy does not guarrantee that it will 
  1177. X     * handle overlapping memory correctly, we will try...
  1178. X     */
  1179. X    if( (myptr1 > myptr2) && (myptr1 < (myptr2+len)) )
  1180. X    {
  1181. X        myptr1 += len;
  1182. X        myptr2 += len;
  1183. X
  1184. X        if( (((long)myptr1)&wordmask) == (((long)myptr2)&wordmask))
  1185. X        {
  1186. X            /*
  1187. X             * if the pointer is not on an even word boundary
  1188. X             */
  1189. X            if( (i = (((long)myptr1) & wordmask)) != 0 )
  1190. X            {
  1191. X                /*
  1192. X                 * process an extra byte at the word boundary
  1193. X                 * itself
  1194. X                 */
  1195. X                while( (i-- > 0) && (len > 0) )
  1196. X                {
  1197. X                    *(--myptr1) = *(--myptr2);
  1198. X                    len--;
  1199. X                }
  1200. X            }
  1201. X
  1202. X            /*
  1203. X             * convert remaining number of bytes to number of words
  1204. X             */
  1205. X            i = len >> (sizeof(word)/2);
  1206. X
  1207. X            /*
  1208. X             * and copy them
  1209. X             */
  1210. X            while( i-- > 0 )
  1211. X            {
  1212. X                myptr1 -= sizeof(word);
  1213. X                myptr2 -= sizeof(word);
  1214. X                *(word *)myptr1 = *(CONST word *)myptr2;
  1215. X            }
  1216. X
  1217. X            /*
  1218. X             * and now handle any trailing bytes
  1219. X             */
  1220. X            if( (i = (len & wordmask)) != 0 )
  1221. X            {
  1222. X                while( i-- > 0 )
  1223. X                {
  1224. X                    *(--myptr1) = *(--myptr2);
  1225. X                }
  1226. X            }
  1227. X        }
  1228. X        /*
  1229. X         * else we have to do it on a byte by byte basis
  1230. X         */
  1231. X        else
  1232. X        {
  1233. X            while( len-- > 0 )
  1234. X            {
  1235. X                *(--myptr1) = *(--myptr2);
  1236. X            }
  1237. X        }
  1238. X    }
  1239. X    else
  1240. X    {
  1241. X        /*
  1242. X         * if we can make this move on even boundaries
  1243. X         */
  1244. X        if( (((long)myptr1)&wordmask) == (((long)myptr2)&wordmask) )
  1245. X        {
  1246. X            /*
  1247. X             * if the pointer is not on an even word boundary
  1248. X             */
  1249. X            if( (i = (((long)myptr1) & wordmask)) != 0 )
  1250. X            {
  1251. X                while( (i++ < sizeof(word)) && (len > 0) )
  1252. X                {
  1253. X                    *(myptr1++) = *(myptr2++);
  1254. X                    len--;
  1255. X                }
  1256. X            }
  1257. X
  1258. X            /*
  1259. X             * convert remaining number of bytes to number of words
  1260. X             */
  1261. X            i = len >> (sizeof(word)/2);
  1262. X
  1263. X            /*
  1264. X             * and copy them
  1265. X             */
  1266. X            while( i-- > 0 )
  1267. X            {
  1268. X                *(word *)myptr1 = *(CONST word *)myptr2;
  1269. X                myptr1 += sizeof(word);
  1270. X                myptr2 += sizeof(word);
  1271. X            }
  1272. X
  1273. X            /*
  1274. X             * and now handle any trailing bytes
  1275. X             */
  1276. X            if( (i = (len & wordmask)) != 0 )
  1277. X            {
  1278. X                while( i-- > 0 )
  1279. X                {
  1280. X                    *(myptr1++) = *(myptr2++);
  1281. X                }
  1282. X            }
  1283. X        }
  1284. X        /*
  1285. X         * else we have to handle it a byte at a time
  1286. X         */
  1287. X        else
  1288. X        {
  1289. X            while( len-- > 0 )
  1290. X            {
  1291. X                *(myptr1++) = *(myptr2++);
  1292. X            }
  1293. X        }
  1294. X    }
  1295. X    
  1296. X    return;
  1297. X
  1298. X} /* DataMC(... */
  1299. X
  1300. X#endif /* ASM_MEMCPY */
  1301. X
  1302. END_OF_FILE
  1303. if test 6395 -ne `wc -c <'datamc.c'`; then
  1304.     echo shar: \"'datamc.c'\" unpacked with wrong size!
  1305. fi
  1306. # end of 'datamc.c'
  1307. fi
  1308. if test -f 'datams.c' -a "${1}" != "-c" ; then 
  1309.   echo shar: Will not clobber existing file \"'datams.c'\"
  1310. else
  1311. echo shar: Extracting \"'datams.c'\" \(2609 characters\)
  1312. sed "s/^X//" >'datams.c' <<'END_OF_FILE'
  1313. X
  1314. X/*
  1315. X * (c) Copyright 1990, 1991, 1992 Conor P. Cahill (cpcahil@virtech.vti.com)
  1316. X *
  1317. X * This software may be distributed freely as long as the following conditions
  1318. X * are met:
  1319. X *         * the distribution, or any derivative thereof, may not be
  1320. X *          included as part of a commercial product
  1321. X *        * full source code is provided including this copyright
  1322. X *        * there is no charge for the software itself (there may be
  1323. X *          a minimal charge for the copying or distribution effort)
  1324. X *        * this copyright notice is not modified or removed from any
  1325. X *          source file
  1326. X */
  1327. X
  1328. X/*
  1329. X * datams.c - this module contains functions designed to efficiently 
  1330. X *          set memory areas to specified values in a portable fasion.
  1331. X *
  1332. X * The configure script will usually override this module with a copy
  1333. X * of the system suplied memset() utility if it can figure out how to
  1334. X * convert the module name to DataMS.
  1335. X */
  1336. X#ifndef lint
  1337. Xstatic
  1338. Xchar rcs_hdr[] = "$Id: datams.c,v 1.4 1992/08/22 16:27:13 cpcahil Exp $";
  1339. X#endif
  1340. X
  1341. X#include <stdio.h>
  1342. X#include "mallocin.h"
  1343. X
  1344. Xtypedef int word;
  1345. X
  1346. X#define wordmask (sizeof(word)-1)
  1347. X#define FILL_ARRSIZ     256
  1348. X
  1349. Xvoid
  1350. XDataMS(ptr1,ch, len)
  1351. X    MEMDATA            * ptr1;
  1352. X    int              ch;
  1353. X    register MEMSIZE      len;
  1354. X{
  1355. X    MEMSIZE              i;
  1356. X    register unsigned char    * ptr;
  1357. X    word              fillword;
  1358. X    static word          fillwords[FILL_ARRSIZ] = { -1 };
  1359. X
  1360. X    /*
  1361. X     * if nothing to do, return immediatly.
  1362. X     */
  1363. X    if( len <= 0 )
  1364. X    {
  1365. X        return;
  1366. X    }
  1367. X
  1368. X    /*
  1369. X     * if we haven't filled the fillwords array
  1370. X     */
  1371. X    if( fillwords[0] == -1 )
  1372. X    {
  1373. X        int          j;
  1374. X        int          k;
  1375. X
  1376. X        /*
  1377. X         * fill em all at this time.
  1378. X         */
  1379. X        for(k=0; k < FILL_ARRSIZ; k++)
  1380. X        {
  1381. X            ptr = (unsigned char *) &fillwords[k];
  1382. X            for(j=0; j < sizeof(word); j++)
  1383. X            {
  1384. X                *(ptr++) = (unsigned char) k;
  1385. X            }
  1386. X        }
  1387. X    }
  1388. X
  1389. X    /*
  1390. X     * if the character is outside of the proper range, use 255
  1391. X      */
  1392. X    if( ((unsigned)ch) > 0xFF )
  1393. X    {
  1394. X        ch = ((unsigned)ch) & 0xFF;
  1395. X    }
  1396. X
  1397. X    /*
  1398. X     * save the word we will use for filling
  1399. X     */
  1400. X    fillword = fillwords[(unsigned)ch];
  1401. X            
  1402. X
  1403. X    /*
  1404. X     * get the original pointer
  1405. X     */
  1406. X    ptr = (unsigned char *) ptr1;
  1407. X
  1408. X    /*
  1409. X     * if we are not at a word offset, handle the single bytes at the
  1410. X     * begining of the set
  1411. X     */
  1412. X    if( (i = (((long)ptr) & wordmask)) != 0 )
  1413. X    {
  1414. X        i = sizeof(word) - i;
  1415. X        while( (i-- > 0) && (len > 0) )
  1416. X        {
  1417. X            *(ptr++) = ch;
  1418. X            len--;
  1419. X        }
  1420. X    }
  1421. X
  1422. X    /*
  1423. X     * convert remaining number of bytes to number of words
  1424. X     */
  1425. X    i = len >> (sizeof(word)/2);
  1426. X
  1427. X    /*
  1428. X     * and fill them
  1429. X     */
  1430. X    while( i-- )
  1431. X    {
  1432. X        *(word *)ptr = fillword;
  1433. X        ptr += sizeof(word);
  1434. X    }
  1435. X
  1436. X    /*
  1437. X     * and now handle any trailing bytes
  1438. X     */
  1439. X    if( (i = (len & wordmask)) != 0 )
  1440. X    {
  1441. X        while(i-- > 0 )
  1442. X        {
  1443. X            *(ptr++) = ch;
  1444. X        }
  1445. X    }
  1446. X
  1447. X    return;
  1448. X
  1449. X} /* DataMS(... */
  1450. X
  1451. END_OF_FILE
  1452. if test 2609 -ne `wc -c <'datams.c'`; then
  1453.     echo shar: \"'datams.c'\" unpacked with wrong size!
  1454. fi
  1455. # end of 'datams.c'
  1456. fi
  1457. if test -f 'debug.h' -a "${1}" != "-c" ; then 
  1458.   echo shar: Will not clobber existing file \"'debug.h'\"
  1459. else
  1460. echo shar: Extracting \"'debug.h'\" \(3307 characters\)
  1461. sed "s/^X//" >'debug.h' <<'END_OF_FILE'
  1462. X/*
  1463. X * (c) Copyright 1990, 1991, 1992 Conor P. Cahill (cpcahil@virtech.vti.com)
  1464. X *
  1465. X * This software may be distributed freely as long as the following conditions
  1466. X * are met:
  1467. X *         * the distribution, or any derivative thereof, may not be
  1468. X *          included as part of a commercial product
  1469. X *        * full source code is provided including this copyright
  1470. X *        * there is no charge for the software itself (there may be
  1471. X *          a minimal charge for the copying or distribution effort)
  1472. X *        * this copyright notice is not modified or removed from any
  1473. X *          source file
  1474. X */
  1475. X/************************************************************************/
  1476. X/*                                    */
  1477. X/* this include sets up some macro functions which can be used while    */
  1478. X/* debugging the program, and then left in the code, but turned of by    */
  1479. X/* just not defining "DEBUG".  This way your production version of     */
  1480. X/* the program will not be filled with bunches of debugging junk    */
  1481. X/*                                    */
  1482. X/************************************************************************/
  1483. X/*
  1484. X * $Id: debug.h,v 1.5 1992/08/22 16:27:13 cpcahil Exp $
  1485. X */
  1486. X
  1487. X#ifdef DEBUG
  1488. X
  1489. X#if DEBUG == 1            /* if default level            */
  1490. X#undef DEBUG
  1491. X#define DEBUG    100        /*   use level 100            */
  1492. X#endif
  1493. X
  1494. X#include <stdio.h>
  1495. X
  1496. X#define DEBUG0(val,str)\
  1497. X                {\
  1498. X                  if( DEBUG > val ) \
  1499. X                    fprintf(stderr,"%s(%d): %s\n",\
  1500. X                        __FILE__,__LINE__,str);\
  1501. X                }
  1502. X#define DEBUG1(val,str,a1)\
  1503. X                    {\
  1504. X                  char _debugbuf[100];\
  1505. X                  if( DEBUG > val )\
  1506. X                   {\
  1507. X                    sprintf(_debugbuf,str,a1);\
  1508. X                    fprintf(stderr,"%s(%d): %s\n",\
  1509. X                        __FILE__,__LINE__,_debugbuf);\
  1510. X                   }\
  1511. X                       }
  1512. X
  1513. X#define DEBUG2(val,str,a1,a2)\
  1514. X                    {\
  1515. X                 char _debugbuf[100];\
  1516. X                  if( DEBUG > val )\
  1517. X                   {\
  1518. X                    sprintf(_debugbuf,str,a1,a2);\
  1519. X                    fprintf(stderr,"%s(%d): %s\n",\
  1520. X                        __FILE__,__LINE__,_debugbuf);\
  1521. X                   }\
  1522. X                       }
  1523. X
  1524. X#define DEBUG3(val,str,a1,a2,a3)\
  1525. X                    {\
  1526. X                  char _debugbuf[100];\
  1527. X                  if( DEBUG > val )\
  1528. X                   {\
  1529. X                    sprintf(_debugbuf,str,a1,a2,a3);\
  1530. X                    fprintf(stderr,"%s(%d): %s\n",\
  1531. X                        __FILE__,__LINE__,_debugbuf);\
  1532. X                   }\
  1533. X                       }
  1534. X
  1535. X#define DEBUG4(val,str,a1,a2,a3,a4)\
  1536. X                     {\
  1537. X                  char _debugbuf[100];\
  1538. X                  if( DEBUG > val )\
  1539. X                   {\
  1540. X                    sprintf(_debugbuf,str,a1,a2,a3,a4);\
  1541. X                    fprintf(stderr,"%s(%d): %s\n",\
  1542. X                        __FILE__,__LINE__,_debugbuf);\
  1543. X                   }\
  1544. X                       }
  1545. X
  1546. X#define DEBUG5(val,str,a1,a2,a3,a4,a5)\
  1547. X                     {\
  1548. X                  char _debugbuf[100];\
  1549. X                  if( DEBUG > val )\
  1550. X                   {\
  1551. X                    sprintf(_debugbuf,str,a1,a2,a3,a4,a5);\
  1552. X                    fprintf(stderr,"%s(%d): %s\n",\
  1553. X                        __FILE__,__LINE__,_debugbuf);\
  1554. X                   }\
  1555. X                       }
  1556. X
  1557. X#else
  1558. X
  1559. X#define DEBUG0(val,s)
  1560. X#define DEBUG1(val,s,a1)
  1561. X#define DEBUG2(val,s,a1,a2)
  1562. X#define DEBUG3(val,s,a1,a2,a3)
  1563. X#define DEBUG4(val,s,a1,a2,a3,a4)
  1564. X#define DEBUG5(val,s,a1,a2,a3,a4,a5)
  1565. X
  1566. X#endif /* DEBUG */
  1567. X
  1568. X
  1569. X/*
  1570. X * $Log: debug.h,v $
  1571. X * Revision 1.5  1992/08/22  16:27:13  cpcahil
  1572. X * final changes for pl14
  1573. X *
  1574. X * Revision 1.4  1992/04/13  03:06:33  cpcahil
  1575. X * Added Stack support, marking of non-leaks, auto-config, auto-testing
  1576. X *
  1577. X * Revision 1.3  1991/11/25  14:41:51  cpcahil
  1578. X * Final changes in preparation for patch 4 release
  1579. X *
  1580. X * Revision 1.2  90/05/11  00:13:08  cpcahil
  1581. X * added copyright statment
  1582. X * 
  1583. X * Revision 1.1  90/02/23  07:09:01  cpcahil
  1584. X * Initial revision
  1585. X * 
  1586. X */
  1587. END_OF_FILE
  1588. if test 3307 -ne `wc -c <'debug.h'`; then
  1589.     echo shar: \"'debug.h'\" unpacked with wrong size!
  1590. fi
  1591. # end of 'debug.h'
  1592. fi
  1593. if test -f 'dgmalloc.c' -a "${1}" != "-c" ; then 
  1594.   echo shar: Will not clobber existing file \"'dgmalloc.c'\"
  1595. else
  1596. echo shar: Extracting \"'dgmalloc.c'\" \(2724 characters\)
  1597. sed "s/^X//" >'dgmalloc.c' <<'END_OF_FILE'
  1598. X
  1599. X/*
  1600. X * (c) Copyright 1990, 1991, 1992 Conor P. Cahill (cpcahil@virtech.vti.com)
  1601. X *
  1602. X * This software may be distributed freely as long as the following conditions
  1603. X * are met:
  1604. X *         * the distribution, or any derivative thereof, may not be
  1605. X *          included as part of a commercial product
  1606. X *        * full source code is provided including this copyright
  1607. X *        * there is no charge for the software itself (there may be
  1608. X *          a minimal charge for the copying or distribution effort)
  1609. X *        * this copyright notice is not modified or removed from any
  1610. X *          source file
  1611. X */
  1612. X/*
  1613. X * Author(s):
  1614. X *  pds - Paul D. Smith (paul_smith@dg.com)
  1615. X */
  1616. X/*
  1617. X * This module defines several libc internal interfaces to the allocation
  1618. X * and/or memory routines under DG/UX.
  1619. X */
  1620. X
  1621. X/*
  1622. X * Added "_" components to make sure that libc versions of other
  1623. X * malloc interfaces called by various libc routines (eg. getcwd) that
  1624. X * must be used from libc do not have competing malloc implementations.
  1625. X */
  1626. X#include <stdio.h>
  1627. X#include "mallocin.h"
  1628. X
  1629. XDATATYPE *
  1630. X_malloc(size)
  1631. X    SIZETYPE size;
  1632. X{
  1633. X    return( debug_malloc(NULL,-1,size) );
  1634. X}
  1635. X
  1636. XDATATYPE *
  1637. X_realloc(cptr,size)
  1638. X    DATATYPE  * cptr;
  1639. X    SIZETYPE    size;
  1640. X{
  1641. X    return( debug_realloc(NULL,-1,cptr,size) );
  1642. X}
  1643. X
  1644. XDATATYPE *
  1645. X_calloc(nelem,elsize)
  1646. X    SIZETYPE       nelem;
  1647. X    SIZETYPE       elsize;
  1648. X{
  1649. X    return( debug_calloc(NULL,-1,nelem,elsize) );
  1650. X}
  1651. X
  1652. Xvoid
  1653. X_free(cptr)
  1654. X    DATATYPE    * cptr;
  1655. X{
  1656. X    debug_free(NULL,0,cptr);
  1657. X}
  1658. X
  1659. Xint
  1660. X_mallopt(cmd,value)
  1661. X    int                    cmd;
  1662. X    union dbmalloptarg    value;
  1663. X{
  1664. X    return( dbmallopt(cmd,&value) );
  1665. X}
  1666. X
  1667. XMEMDATA  *
  1668. X_bcopy(ptr2, ptr1, len)
  1669. X    CONST MEMDATA    * ptr2;
  1670. X    MEMDATA        * ptr1;
  1671. X    MEMSIZE          len;
  1672. X{
  1673. X    return( DBbcopy((char *)NULL,0,ptr2,ptr1,len) );
  1674. X}
  1675. X
  1676. XMEMDATA  *
  1677. X_bzero(ptr1, len)
  1678. X    MEMDATA        * ptr1;
  1679. X    MEMSIZE          len;
  1680. X{
  1681. X    return( DBbzero((char *)NULL,0,ptr1,len) );
  1682. X}
  1683. X
  1684. Xint
  1685. X_bcmp(ptr2, ptr1, len)
  1686. X    CONST MEMDATA    * ptr1;
  1687. X    CONST MEMDATA    * ptr2;
  1688. X    MEMSIZE          len;
  1689. X{
  1690. X    return( DBbcmp((char *)NULL,0,ptr2, ptr1, len) );
  1691. X}
  1692. X
  1693. XMEMDATA  *
  1694. X__dg_bcopy(ptr2, ptr1, len)
  1695. X    CONST MEMDATA    * ptr2;
  1696. X    MEMDATA        * ptr1;
  1697. X    MEMSIZE          len;
  1698. X{
  1699. X    return( DBbcopy((char *)NULL,0,ptr2,ptr1,len) );
  1700. X}
  1701. X
  1702. XMEMDATA  *
  1703. X__dg_bzero(ptr1, len)
  1704. X    MEMDATA        * ptr1;
  1705. X    MEMSIZE          len;
  1706. X{
  1707. X    return( DBbzero((char *)NULL,0,ptr1,len) );
  1708. X}
  1709. X
  1710. Xint
  1711. X__dg_bcmp(ptr2, ptr1, len)
  1712. X    CONST MEMDATA    * ptr1;
  1713. X    CONST MEMDATA    * ptr2;
  1714. X    MEMSIZE          len;
  1715. X{
  1716. X    return( DBbcmp((char *)NULL,0,ptr2, ptr1, len) );
  1717. X}
  1718. X
  1719. X
  1720. X/*
  1721. X * $Log: dgmalloc.c,v $
  1722. X * Revision 1.4  1992/08/22  16:27:13  cpcahil
  1723. X * final changes for pl14
  1724. X *
  1725. X * Revision 1.3  1992/07/03  00:03:25  cpcahil
  1726. X * more fixes for pl13, several suggestons from Rich Salz.
  1727. X *
  1728. X * Revision 1.2  1992/07/02  15:35:52  cpcahil
  1729. X * misc cleanups for PL13
  1730. X *
  1731. X * Revision 1.1  1992/05/06  04:53:29  cpcahil
  1732. X * performance enhancments
  1733. X *
  1734. X */
  1735. END_OF_FILE
  1736. if test 2724 -ne `wc -c <'dgmalloc.c'`; then
  1737.     echo shar: \"'dgmalloc.c'\" unpacked with wrong size!
  1738. fi
  1739. # end of 'dgmalloc.c'
  1740. fi
  1741. if test -f 'dump.c' -a "${1}" != "-c" ; then 
  1742.   echo shar: Will not clobber existing file \"'dump.c'\"
  1743. else
  1744. echo shar: Extracting \"'dump.c'\" \(11008 characters\)
  1745. sed "s/^X//" >'dump.c' <<'END_OF_FILE'
  1746. X
  1747. X/*
  1748. X * (c) Copyright 1990, 1991, 1992 Conor P. Cahill (cpcahil@virtech.vti.com)
  1749. X *
  1750. X * This software may be distributed freely as long as the following conditions
  1751. X * are met:
  1752. X *         * the distribution, or any derivative thereof, may not be
  1753. X *          included as part of a commercial product
  1754. X *        * full source code is provided including this copyright
  1755. X *        * there is no charge for the software itself (there may be
  1756. X *          a minimal charge for the copying or distribution effort)
  1757. X *        * this copyright notice is not modified or removed from any
  1758. X *          source file
  1759. X */
  1760. X#include <stdio.h>
  1761. X#include "mallocin.h"
  1762. X#include "tostring.h"
  1763. X
  1764. X#ifndef lint
  1765. Xstatic
  1766. Xchar rcs_hdr[] = "$Id: dump.c,v 1.20 1992/08/22 16:27:13 cpcahil Exp $";
  1767. X#endif
  1768. X
  1769. X/*
  1770. X * various macro definitions used within this module.
  1771. X */
  1772. X
  1773. X#define WRITEOUT(fd,str,len)    if( write(fd,str,(WRTSIZE)(len)) != (len) ) \
  1774. X                { \
  1775. X                    VOIDCAST write(2,ERRSTR,\
  1776. X                             (WRTSIZE)strlen(ERRSTR));\
  1777. X                    exit(120); \
  1778. X                }
  1779. X
  1780. X#define DETAIL_NONE         0
  1781. X#define DETAIL_NOT_SET_YET    -1
  1782. X#define DETAIL_ST_COL        (sizeof(DETAIL_HDR_3)-1)
  1783. X#define ERRSTR    "I/O Error on malloc dump file descriptor\n"
  1784. X#define FILE_LEN        20
  1785. X#define LIST_ALL        1
  1786. X#define LIST_SOME        2
  1787. X#define NUM_BYTES        7
  1788. X#define TITLE            " Dump of Malloc Chain "
  1789. X
  1790. X#define DETAIL_HDR_1 \
  1791. X     "                             FREE     FREE                  ACTUAL SIZE    "
  1792. X#define DETAIL_HDR_2 \
  1793. X     "  PTR      NEXT     PREV     NEXT     PREV      FLAGS       INT    HEX     "
  1794. X#define DETAIL_HDR_3 \
  1795. X     "-------- -------- -------- -------- -------- ---------- -------- --------- "
  1796. X
  1797. X#define NORMAL_HDR_1 \
  1798. X "POINTER     FILE  WHERE         LINE      ALLOC        DATA     HEX DUMP   \n"
  1799. X#define NORMAL_HDR_2 \
  1800. X "TO DATA      ALLOCATED         NUMBER     FUNCT       LENGTH  OF BYTES 1-7 \n"
  1801. X#define NORMAL_HDR_3 \
  1802. X "-------- -------------------- ------- -------------- ------- --------------\n"
  1803. X
  1804. X#define THISBUFSIZE (sizeof(NORMAL_HDR_3)+sizeof(DETAIL_HDR_3))
  1805. X
  1806. X
  1807. X/*
  1808. X * Function:    malloc_dump()
  1809. X *
  1810. X * Purpose:    to dump a printed copy of the malloc chain and
  1811. X *        associated data elements
  1812. X *
  1813. X * Arguments:    fd    - file descriptor to write data to
  1814. X *
  1815. X * Returns:    nothing of any use
  1816. X *
  1817. X * Narrative:    Just print out all the junk
  1818. X *
  1819. X */
  1820. XVOIDTYPE
  1821. Xmalloc_dump(fd)
  1822. X    int        fd;
  1823. X{
  1824. X    malloc_list_items(fd,LIST_ALL,0L,0L);
  1825. X}
  1826. X
  1827. X/*
  1828. X * Function:    malloc_list()
  1829. X *
  1830. X * Purpose:    to dump a printed copy of the malloc chain and
  1831. X *        associated data elements
  1832. X *
  1833. X * Arguments:    fd    - file descriptor to write data to
  1834. X *        histid1 - id of the first record to display
  1835. X *        histid2 - id one above the last record to display
  1836. X *
  1837. X * Returns:    nothing of any use
  1838. X *
  1839. X * Narrative:    Just call malloc_list_items to display the junk
  1840. X *
  1841. X */
  1842. XVOIDTYPE
  1843. Xmalloc_list(fd,histid1,histid2)
  1844. X    int        fd;
  1845. X    IDTYPE        histid1;
  1846. X    IDTYPE        histid2;
  1847. X{
  1848. X    malloc_list_items(fd, LIST_SOME, histid1, histid2);
  1849. X}
  1850. X
  1851. X/*
  1852. X * Function:    malloc_list_items()
  1853. X *
  1854. X * Purpose:    to dump a printed copy of the malloc chain and
  1855. X *        associated data elements
  1856. X *
  1857. X * Arguments:    fd      - file descriptor to write data to
  1858. X *        list_type - type of list (all records, or a selected list)
  1859. X *        histid1      - first id to list (if type is some)
  1860. X *        histid2   - one above last id to list
  1861. X *
  1862. X * Returns:    nothing of any use
  1863. X *
  1864. X * Narrative:    Just print out all the junk
  1865. X *
  1866. X * Notes:    This function is implemented using low level calls because
  1867. X *         of the likelyhood that the malloc tree is damaged when it
  1868. X *        is called.  (Lots of things in the c library use malloc and
  1869. X *        we don't want to get into a catch-22).
  1870. X *
  1871. X */
  1872. XVOIDTYPE
  1873. Xmalloc_list_items(fd,list_type,histid1,histid2)
  1874. X    int              fd;
  1875. X    int              list_type;
  1876. X    IDTYPE              histid1;
  1877. X    IDTYPE              histid2;
  1878. X{
  1879. X    char              buffer[THISBUFSIZE];
  1880. X    int              detail;
  1881. X    int              first_time = 1;
  1882. X    CONST char        * func;
  1883. X    int              i;
  1884. X    int              loc;
  1885. X    struct mlist         * ptr;
  1886. X
  1887. X    MALLOC_INIT();
  1888. X
  1889. X    if( (malloc_opts & MOPT_DETAIL) != 0 )
  1890. X    {
  1891. X        detail = DETAIL_ST_COL;
  1892. X    }
  1893. X    else
  1894. X    {
  1895. X        detail = DETAIL_NONE;
  1896. X    }
  1897. X
  1898. X    /*
  1899. X     * for each element in the trace
  1900. X     */
  1901. X    for(ptr = &malloc_start; ptr; ptr = ptr->next)
  1902. X    {
  1903. X        /*
  1904. X         * if this item is not in use or it is a stack element
  1905. X         *     and we are not in detail mode or list-all mode.
  1906. X         */
  1907. X        if(  ( ((ptr->flag & M_INUSE)==0) || (GETTYPE(ptr)==M_T_STACK) )
  1908. X            && ((detail == DETAIL_NONE) || (list_type != LIST_ALL)) )
  1909. X        {
  1910. X            continue;
  1911. X        }
  1912. X        /*
  1913. X         * else if we are only listing a range of items, check to see
  1914. X         * if this item is in the correct range and is not marked. 
  1915. X         * if not, skip it
  1916. X          */
  1917. X        else if(   (list_type == LIST_SOME)
  1918. X            && (    (ptr->hist_id < histid1)
  1919. X                 || (ptr->hist_id >= histid2)
  1920. X                 || ((ptr->flag & M_MARKED) != 0) ) )
  1921. X        {
  1922. X            continue;
  1923. X        }
  1924. X
  1925. X        /*
  1926. X         * if this is the first time, put out the headers.
  1927. X         */
  1928. X        if( first_time )
  1929. X        {
  1930. X            /*
  1931. X             * fill the title line with asterisks
  1932. X             */
  1933. X            for(i=0; i < (detail + sizeof(NORMAL_HDR_3)-1); i++)
  1934. X            {
  1935. X                buffer[i] = '*';
  1936. X            }
  1937. X            buffer[i] = '\n';
  1938. X            buffer[i+1] = EOS;
  1939. X
  1940. X            /*
  1941. X             * add in the title  (centered, of course)
  1942. X             */
  1943. X            loc = (i - sizeof(TITLE)) / 2;
  1944. X            for(i=0; i < (sizeof(TITLE)-1); i++)
  1945. X            {
  1946. X                buffer[loc+i] = TITLE[i];
  1947. X            }
  1948. X
  1949. X            /*
  1950. X             * and write it out
  1951. X             */
  1952. X            WRITEOUT(fd,buffer,strlen(buffer));
  1953. X
  1954. X            /*
  1955. X             * write out the column headers
  1956. X             */
  1957. X            if( detail != DETAIL_NONE )
  1958. X            {
  1959. X                WRITEOUT(fd,DETAIL_HDR_1,
  1960. X                        sizeof(DETAIL_HDR_1)-1);
  1961. X                WRITEOUT(fd,NORMAL_HDR_1,
  1962. X                        sizeof(NORMAL_HDR_1)-1);
  1963. X                WRITEOUT(fd,DETAIL_HDR_2,
  1964. X                        sizeof(DETAIL_HDR_2)-1);
  1965. X                WRITEOUT(fd,NORMAL_HDR_2,
  1966. X                        sizeof(NORMAL_HDR_2)-1);
  1967. X                WRITEOUT(fd,DETAIL_HDR_3,
  1968. X                        sizeof(DETAIL_HDR_3)-1);
  1969. X                WRITEOUT(fd,NORMAL_HDR_3,
  1970. X                        sizeof(NORMAL_HDR_3)-1);
  1971. X            }
  1972. X            else
  1973. X            {
  1974. X                WRITEOUT(fd,NORMAL_HDR_1,
  1975. X                        sizeof(NORMAL_HDR_1)-1);
  1976. X                WRITEOUT(fd,NORMAL_HDR_2,
  1977. X                        sizeof(NORMAL_HDR_2)-1);
  1978. X                WRITEOUT(fd,NORMAL_HDR_3,
  1979. X                        sizeof(NORMAL_HDR_3)-1);
  1980. X            }
  1981. X
  1982. X            first_time = 0;
  1983. X        }
  1984. X
  1985. X        /*
  1986. X         * fill in the string with blanks
  1987. X         */
  1988. X        for(i=0; i < (sizeof(DETAIL_HDR_3)+sizeof(NORMAL_HDR_3)); i++)
  1989. X        {
  1990. X            buffer[i] = ' ';
  1991. X        }
  1992. X
  1993. X        /*
  1994. X          * handle detail output
  1995. X         */
  1996. X        if( detail != DETAIL_NONE )
  1997. X        {
  1998. X            VOIDCAST tostring(buffer,
  1999. X                    (ULONG)ptr,8,B_HEX,'0');
  2000. X            VOIDCAST tostring(buffer+9,
  2001. X                    (ULONG)ptr->next,8,B_HEX,'0');
  2002. X            VOIDCAST tostring(buffer+18,
  2003. X                    (ULONG)ptr->prev,8,B_HEX,'0');
  2004. X            VOIDCAST tostring(buffer+27,
  2005. X                    (ULONG)ptr->freenext,8,B_HEX,'0');
  2006. X            VOIDCAST tostring(buffer+36,
  2007. X                    (ULONG)ptr->freeprev,8,B_HEX,'0');
  2008. X            VOIDCAST tostring(buffer+45,
  2009. X                    (ULONG)ptr->flag,10,B_HEX,'0');
  2010. X            VOIDCAST tostring(buffer+56,
  2011. X                    (ULONG)ptr->s.size,8,B_DEC,' ');
  2012. X            VOIDCAST tostring(buffer+65,
  2013. X                    (ULONG)ptr->s.size,8,B_HEX,'0');
  2014. X            buffer[64] = '(';
  2015. X            buffer[74] = ')';
  2016. X        }
  2017. X
  2018. X        /*
  2019. X         * and now add in the normal stuff
  2020. X         */
  2021. X         VOIDCAST tostring(buffer+detail,
  2022. X                (ULONG) ptr->data, 8, B_HEX, '0');
  2023. X
  2024. X        /*
  2025. X         * if a file has been specified
  2026. X         */
  2027. X        if( (ptr->file != NULL)     && (ptr->file[0] != EOS) )
  2028. X        {
  2029. X
  2030. X            for(i=0; (i < FILE_LEN) && (ptr->file[i] != EOS); i++)
  2031. X            {
  2032. X                buffer[detail+9+i] = ptr->file[i];
  2033. X            }
  2034. X
  2035. X            VOIDCAST tostring(buffer+detail+30,
  2036. X                        (ULONG)ptr->line,7,B_DEC, ' ');
  2037. X        }
  2038. X        else
  2039. X        {
  2040. X            for(i=0; i < (sizeof("unknown")-1); i++)
  2041. X            {
  2042. X                buffer[detail+9+i] = "unknown"[i];
  2043. X            }
  2044. X        }
  2045. X            
  2046. X        func = MallocFuncName(ptr);
  2047. X        /*
  2048. X         * copy the function name into the string.
  2049. X         */
  2050. X        for( i=0; func[i] != EOS; i++)
  2051. X        {
  2052. X            buffer[detail+38+i] = func[i];
  2053. X        }
  2054. X
  2055. X        /*
  2056. X         * add the call number
  2057. X         */
  2058. X        buffer[detail+38+ i++] = '(';
  2059. X        i += tostring(buffer+detail+38+i,(ULONG)ptr->id,0,B_DEC,' ');
  2060. X        buffer[detail+38+i] = ')';
  2061. X    
  2062. X        /*
  2063. X         * display the length of the segment
  2064. X         */
  2065. X        VOIDCAST tostring(buffer+detail+53,
  2066. X                (ULONG)ptr->r_size,7,B_DEC,' ');
  2067. X
  2068. X        /* 
  2069. X         * display the first seven bytes of data
  2070. X         */
  2071. X        for( i=0; (i < NUM_BYTES) && (i < ptr->r_size); i++)
  2072. X        {
  2073. X            VOIDCAST tostring(buffer+detail + 61 + (i * 2),
  2074. X                    (ULONG)ptr->data[i], 2, B_HEX, '0');
  2075. X        }
  2076. X
  2077. X        buffer[detail + sizeof(NORMAL_HDR_3)] = '\n';
  2078. X        WRITEOUT(fd,buffer,detail+sizeof(NORMAL_HDR_3)+1);
  2079. X
  2080. X        /*
  2081. X         * and dump any stack info (if it was specified by the user)
  2082. X         */
  2083. X        StackDump(fd,(char *) NULL,ptr->stack);
  2084. X
  2085. X    }
  2086. X
  2087. X    if( detail != DETAIL_NONE )
  2088. X    {
  2089. X        WRITEOUT(fd,"Malloc start:      ",19);
  2090. X        VOIDCAST tostring(buffer, (ULONG)&malloc_start, 10, B_HEX, '0');
  2091. X        buffer[10] = '\n';
  2092. X        WRITEOUT(fd,buffer,11);
  2093. X
  2094. X        WRITEOUT(fd,"Malloc end:        ", 19);
  2095. X        VOIDCAST tostring(buffer, (ULONG) malloc_end, 10, B_HEX, '0');
  2096. X        buffer[10] = '\n';
  2097. X        WRITEOUT(fd,buffer,11);
  2098. X
  2099. X        WRITEOUT(fd,"Malloc data start: ", 19);
  2100. X        VOIDCAST tostring(buffer,(ULONG)malloc_data_start,10,B_HEX,'0');
  2101. X        buffer[10] = '\n';
  2102. X        WRITEOUT(fd,buffer,11);
  2103. X
  2104. X        WRITEOUT(fd,"Malloc data end:   ", 19);
  2105. X        VOIDCAST tostring(buffer,(ULONG)malloc_data_end, 10,B_HEX, '0');
  2106. X        buffer[10] = '\n';
  2107. X        WRITEOUT(fd,buffer,11);
  2108. X
  2109. X        WRITEOUT(fd,"Malloc free list:  ", 19);
  2110. X        VOIDCAST tostring(buffer, (ULONG)malloc_freelist, 10,B_HEX,'0');
  2111. X        buffer[10] = '\n';
  2112. X        WRITEOUT(fd,buffer,11);
  2113. X
  2114. X        for(ptr=malloc_freelist->freenext; ptr!=NULL; ptr=ptr->freenext)
  2115. X        {
  2116. X            WRITEOUT(fd,"                -> ", 19);
  2117. X            VOIDCAST tostring(buffer, (ULONG) ptr, 10, B_HEX, '0');
  2118. X            buffer[10] = '\n';
  2119. X            WRITEOUT(fd,buffer,11);
  2120. X        }
  2121. X
  2122. X    }
  2123. X
  2124. X    WRITEOUT(fd,"\n",1);
  2125. X    
  2126. X} /* malloc_dump(... */
  2127. X
  2128. X
  2129. X/*
  2130. X * $Log: dump.c,v $
  2131. X * Revision 1.20  1992/08/22  16:27:13  cpcahil
  2132. X * final changes for pl14
  2133. X *
  2134. X * Revision 1.19  1992/06/30  13:06:39  cpcahil
  2135. X * added support for aligned allocations
  2136. X *
  2137. X * Revision 1.18  1992/06/22  23:40:10  cpcahil
  2138. X * many fixes for working on small int systems
  2139. X *
  2140. X * Revision 1.17  1992/05/08  02:30:35  cpcahil
  2141. X * minor cleanups from minix/atari port
  2142. X *
  2143. X * Revision 1.16  1992/04/24  12:09:13  cpcahil
  2144. X * (hopefully) final cleanup for patch 10
  2145. X *
  2146. X * Revision 1.15  1992/04/22  18:17:32  cpcahil
  2147. X * added support for Xt Alloc functions, linted code
  2148. X *
  2149. X * Revision 1.14  1992/04/15  12:51:06  cpcahil
  2150. X * fixes per testing of patch 8
  2151. X *
  2152. X * Revision 1.13  1992/04/14  02:27:30  cpcahil
  2153. X * adjusted output of pointes so that values that had the high bit
  2154. X * set would print correctly.
  2155. X *
  2156. X * Revision 1.12  1992/04/13  19:57:15  cpcahil
  2157. X * more patch 8 fixes
  2158. X *
  2159. X * Revision 1.11  1992/04/13  03:06:33  cpcahil
  2160. X * Added Stack support, marking of non-leaks, auto-config, auto-testing
  2161. X *
  2162. X * Revision 1.10  1992/01/30  12:23:06  cpcahil
  2163. X * renamed mallocint.h -> mallocin.h
  2164. X *
  2165. X * Revision 1.9  1992/01/10  17:28:03  cpcahil
  2166. X * Added support for overriding void datatype
  2167. X *
  2168. X * Revision 1.8  1991/12/04  09:23:36  cpcahil
  2169. X * several performance enhancements including addition of free list
  2170. X *
  2171. X * Revision 1.7  91/11/25  14:41:52  cpcahil
  2172. X * Final changes in preparation for patch 4 release
  2173. X * 
  2174. X * Revision 1.6  91/11/24  00:49:25  cpcahil
  2175. X * first cut at patch 4
  2176. X * 
  2177. X * Revision 1.5  90/08/29  21:22:37  cpcahil
  2178. X * miscellaneous lint fixes
  2179. X * 
  2180. X * Revision 1.4  90/05/11  00:13:08  cpcahil
  2181. X * added copyright statment
  2182. X * 
  2183. X * Revision 1.3  90/02/24  21:50:07  cpcahil
  2184. X * lots of lint fixes
  2185. X * 
  2186. X * Revision 1.2  90/02/24  17:27:48  cpcahil
  2187. X * changed $header to $Id to remove full path from rcs id string
  2188. X * 
  2189. X * Revision 1.1  90/02/22  23:17:43  cpcahil
  2190. X * Initial revision
  2191. X * 
  2192. X */
  2193. END_OF_FILE
  2194. if test 11008 -ne `wc -c <'dump.c'`; then
  2195.     echo shar: \"'dump.c'\" unpacked with wrong size!
  2196. fi
  2197. # end of 'dump.c'
  2198. fi
  2199. if test -f 'fill.c' -a "${1}" != "-c" ; then 
  2200.   echo shar: Will not clobber existing file \"'fill.c'\"
  2201. else
  2202. echo shar: Extracting \"'fill.c'\" \(7792 characters\)
  2203. sed "s/^X//" >'fill.c' <<'END_OF_FILE'
  2204. X/*
  2205. X * (c) Copyright 1990, 1991, 1992 Conor P. Cahill (cpcahil@virtech.vti.com)
  2206. X *
  2207. X * This software may be distributed freely as long as the following conditions
  2208. X * are met:
  2209. X *         * the distribution, or any derivative thereof, may not be
  2210. X *          included as part of a commercial product
  2211. X *        * full source code is provided including this copyright
  2212. X *        * there is no charge for the software itself (there may be
  2213. X *          a minimal charge for the copying or distribution effort)
  2214. X *        * this copyright notice is not modified or removed from any
  2215. X *          source file
  2216. X */
  2217. X#include <stdio.h>
  2218. X#include "mallocin.h"
  2219. X
  2220. Xstatic long     fillmalloc = -1;
  2221. Xstatic long     fillfree   = -1;
  2222. X
  2223. X#define FILLINIT() if( fillmalloc == -1 )  FillInit()
  2224. X
  2225. X
  2226. X/*
  2227. X * Fill check types
  2228. X */
  2229. X#define FILL_UNDER     1
  2230. X#define FILL_OVER    2
  2231. X#define FILL_FREED    3
  2232. X
  2233. X/*
  2234. X * FillInit() - fill initialization routine
  2235. X */
  2236. XVOIDTYPE
  2237. XFillInit()
  2238. X{
  2239. X    char    * ptr;
  2240. X    int      i;
  2241. X    
  2242. X    ptr = (char *) &fillmalloc;
  2243. X
  2244. X    for( i=0; i < sizeof(long); i++)
  2245. X    {
  2246. X        *ptr++ = M_FILL;
  2247. X    }
  2248. X
  2249. X    ptr = (char *) &fillfree;
  2250. X
  2251. X    for( i=0; i < sizeof(long); i++)
  2252. X    {
  2253. X        *ptr++ = M_FREE_FILL;
  2254. X    }
  2255. X
  2256. X} /* FillInit(... */
  2257. X
  2258. X/*
  2259. X * FillCheck()    check for overflow and/or underflow using the filled regions
  2260. X *        in the specified malloc segment.
  2261. X */
  2262. Xint
  2263. XFillCheck(func,file,line,ptr,showerrors)
  2264. X    CONST char    * func;
  2265. X    CONST char    * file;
  2266. X    int          line;
  2267. X    struct mlist    * ptr;
  2268. X    int          showerrors;
  2269. X{
  2270. X    int          rtn = -1;
  2271. X
  2272. X    FILLINIT();
  2273. X
  2274. X    /*
  2275. X     * if this block has no filling
  2276. X     */
  2277. X    if( (ptr->flag & (M_FILLED|M_DFILLED)) == 0 )
  2278. X    {
  2279. X        rtn = 0;
  2280. X    }
  2281. X    /*
  2282. X     * else if this block is in use or it was not free-filled
  2283. X     */
  2284. X    else if(    ((ptr->flag & M_INUSE)  != 0) 
  2285. X         || ((ptr->flag & M_FILLED) == 0) )
  2286. X    {
  2287. X        /*
  2288. X         * check for data underflow and data overflow
  2289. X         */
  2290. X        rtn =   FillCheckData(func,file,line,ptr,FILL_UNDER,showerrors)
  2291. X              + FillCheckData(func,file,line,ptr,FILL_OVER, showerrors);
  2292. X    }
  2293. X    /*
  2294. X     * else the block must have been freed
  2295. X     */
  2296. X    else
  2297. X    {
  2298. X        /*
  2299. X         * check for data underflow and free filling
  2300. X         */
  2301. X        rtn =   FillCheckData(func,file,line,ptr,FILL_UNDER,showerrors)
  2302. X              + FillCheckData(func,file,line,ptr,FILL_FREED,showerrors);
  2303. X    }
  2304. X
  2305. X    return(rtn);
  2306. X
  2307. X} /* FillCheck(... */
  2308. X
  2309. X/*
  2310. X * FillCheckData() - routine to check the data areas to ensure that they
  2311. X *          are filled with the appropriate fill characters.
  2312. X */
  2313. Xint
  2314. XFillCheckData(func,file,line,ptr,checktype,showerrors)
  2315. X    CONST char    * func;
  2316. X    CONST char    * file;
  2317. X    int          line;
  2318. X    struct mlist    * ptr;
  2319. X    int          checktype;
  2320. X    int          showerrors;
  2321. X{
  2322. X    register char        * data = NULL;
  2323. X    int              errcode = 0;
  2324. X    char              filler = '\0';
  2325. X    long              fillword = 0;
  2326. X    register SIZETYPE      i = 0;
  2327. X    register long        * ldata;
  2328. X    SIZETYPE          limit = ptr->s.size;
  2329. X    int              rtn = -1;
  2330. X
  2331. X    if( (ptr->flag & (M_DFILLED | M_FILLED)) == 0 )
  2332. X    {
  2333. X        return(0);
  2334. X    }
  2335. X
  2336. X    switch(checktype)
  2337. X    {
  2338. X        case FILL_UNDER:
  2339. X            if(    ((ptr->flag & M_DFILLED) == 0 )
  2340. X                || (ptr->s.filler[LONGFILL-1] == fillmalloc) )
  2341. X            {
  2342. X                rtn = 0;
  2343. X            }
  2344. X            else
  2345. X            {
  2346. X
  2347. X                /*
  2348. X                 * if showing errors
  2349. X                  */
  2350. X                if( showerrors )
  2351. X                {
  2352. X                    /*
  2353. X                     * give the underrun error message
  2354. X                     */
  2355. X                    malloc_errno = M_CODE_UNDERRUN;
  2356. X                    malloc_warning(func,file,line,ptr);
  2357. X                    /*
  2358. X                     * fix the problem
  2359. X                     */
  2360. X                    ptr->s.filler[LONGFILL-1] = fillmalloc;
  2361. X                }
  2362. X                rtn = 1;
  2363. X            }
  2364. X            break;
  2365. X
  2366. X        case FILL_OVER:
  2367. X            if( (ptr->flag & M_DFILLED) == 0)
  2368. X            {
  2369. X                rtn = 0;
  2370. X            }
  2371. X            else
  2372. X            {
  2373. X                i        = ptr->r_size;
  2374. X                errcode  = M_CODE_OVERRUN;
  2375. X                filler   = M_FILL;
  2376. X                fillword = fillmalloc;
  2377. X                data     = ptr->data;
  2378. X            }
  2379. X            break;
  2380. X
  2381. X        case FILL_FREED:
  2382. X            if( (ptr->flag & M_FILLED) == 0)
  2383. X            {
  2384. X                rtn = 0;
  2385. X            }
  2386. X            else
  2387. X            {
  2388. X                i        = 0;
  2389. X                errcode  = M_CODE_REUSE;
  2390. X                filler   = M_FREE_FILL;
  2391. X                fillword = fillfree;
  2392. X                data     = ptr->data;
  2393. X            }
  2394. X            break;
  2395. X
  2396. X        default:
  2397. X            i = 0; 
  2398. X            limit = 0;
  2399. X            break;
  2400. X    }
  2401. X
  2402. X    /*
  2403. X     * if there is nothing to check, just return 
  2404. X     */
  2405. X    if( rtn != -1 )
  2406. X    {
  2407. X        return(rtn);
  2408. X    }
  2409. X            
  2410. X    rtn = 0;
  2411. X    data += i;
  2412. X    i = limit - i;
  2413. X    while( ((long)data) & (sizeof(long)-1) )
  2414. X    {
  2415. X        if( *data != filler )
  2416. X        {
  2417. X            if( showerrors )
  2418. X            {
  2419. X                malloc_errno = errcode;
  2420. X                malloc_warning(func,file,line,ptr);
  2421. X
  2422. X                /*
  2423. X                 * fix the underrun so we only get this
  2424. X                 * message once
  2425. X                 */
  2426. X                while( i-- > 0 )
  2427. X                {
  2428. X                    *(data++) = filler;
  2429. X                }
  2430. X            }
  2431. X
  2432. X            rtn++;
  2433. X                    
  2434. X            break;
  2435. X        }
  2436. X        data++;
  2437. X        i--;
  2438. X    }
  2439. X
  2440. X    /*
  2441. X     * if we haven't found an error yet
  2442. X     */
  2443. X    if( rtn == 0 )
  2444. X    {
  2445. X        /*
  2446. X         * convert to use longword pointer
  2447. X         */
  2448. X        ldata = (long *) data;
  2449. X        i >>= 2;
  2450. X
  2451. X        /*
  2452. X         * while more longwords to check
  2453. X         */    
  2454. X        while( i > 0 )
  2455. X        {
  2456. X            if( *ldata != fillword )
  2457. X            {
  2458. X                if( showerrors )
  2459. X                {
  2460. X                    malloc_errno = errcode;
  2461. X                    malloc_warning(func,file,line,ptr);
  2462. X    
  2463. X                    /*
  2464. X                     * fix the underrun so we only get this
  2465. X                     * message once
  2466. X                     */
  2467. X                    while( i-- > 0 )
  2468. X                    {
  2469. X                        *(ldata++) = fillword;
  2470. X                    }
  2471. X                }
  2472. X    
  2473. X                rtn++;
  2474. X                break;
  2475. X            }
  2476. X
  2477. X            ldata++;
  2478. X            i--;
  2479. X        
  2480. X        }
  2481. X        
  2482. X    }
  2483. X
  2484. X    return(rtn);
  2485. X
  2486. X} /* FillCheckData(... */
  2487. X
  2488. X/*
  2489. X * FillData()    fill in the needed areas in the specified segment.  This is used
  2490. X *        to place non-zero data in new malloc segments, setup boundary
  2491. X *        areas to catch under/overflow, and overwrite freed segments so 
  2492. X *        that they can't be usefully re-used.
  2493. X */
  2494. Xvoid
  2495. XFillData(ptr,alloctype,start,nextptr)
  2496. X    register struct mlist    * ptr;
  2497. X    int              alloctype;
  2498. X    SIZETYPE          start;
  2499. X    struct mlist        * nextptr;
  2500. X{
  2501. X    int          fills;
  2502. X    int          filler = 0;
  2503. X    SIZETYPE      limit = ptr->s.size;
  2504. X    
  2505. X    FILLINIT();
  2506. X
  2507. X    if( (malloc_opts & (MOPT_MFILL|MOPT_DFILL|MOPT_FFILL)) == 0)
  2508. X    {
  2509. X        ptr->flag &= ~(M_FILLED|M_DFILLED);
  2510. X        return;
  2511. X    }
  2512. X
  2513. X    switch(alloctype)
  2514. X    {
  2515. X        case FILL_MALLOC:
  2516. X            fills = MOPT_MFILL | MOPT_DFILL;
  2517. X            filler = M_FILL;
  2518. X            break;
  2519. X
  2520. X        case FILL_FREE:
  2521. X            fills = MOPT_FFILL;
  2522. X            filler = M_FREE_FILL;
  2523. X            break;
  2524. X
  2525. X        case FILL_SPLIT:
  2526. X            fills = MOPT_FFILL;
  2527. X            filler = M_FREE_FILL;
  2528. X            break;
  2529. X
  2530. X        case FILL_JOIN:
  2531. X            if( (ptr->flag&M_INUSE) != 0 )
  2532. X            {
  2533. X                if( ptr->flag & M_FILLED )
  2534. X                {
  2535. X                    fills = MOPT_MFILL;
  2536. X                    filler = M_FILL;
  2537. X                }
  2538. X                else if(  ptr->flag & M_DFILLED )
  2539. X                {
  2540. X                    fills = MOPT_MFILL;
  2541. X                    filler = M_FILL;
  2542. X                    start = ptr->r_size;;
  2543. X                }
  2544. X                else
  2545. X                {
  2546. X                    fills = 0;
  2547. X                }
  2548. X            }
  2549. X            else /* not in use */
  2550. X            {
  2551. X                /*
  2552. X                 * if this segment has bee free-filled
  2553. X                 */
  2554. X                if( ptr->flag & M_FILLED )
  2555. X                {
  2556. X                    fills = MOPT_MFILL;
  2557. X                    filler = M_FREE_FILL;
  2558. X
  2559. X                    /*
  2560. X                     * if the next segment is already filled
  2561. X                     */
  2562. X                    if( (nextptr->flag & M_FILLED) != 0 )
  2563. X                    {
  2564. X                        limit = start + M_SIZE;
  2565. X                    }
  2566. X                }
  2567. X                /*
  2568. X                 * else if this segment has overflow filling
  2569. X                 * enabled, fill the next segment since it is
  2570. X                 * now overflow of this segment.
  2571. X                 */
  2572. X                else if( (ptr->flag & M_DFILLED) != 0 )
  2573. X                {
  2574. X                    fills = MOPT_DFILL;
  2575. X                    filler = M_FILL;
  2576. X                    start = ptr->r_size;;
  2577. X                }
  2578. X                else
  2579. X                {
  2580. X                    fills = 0;
  2581. X                }
  2582. X            }
  2583. X            break;
  2584. X
  2585. X        case FILL_REALLOC:
  2586. X            if( ptr->flag & M_FILLED )
  2587. X            {
  2588. X                fills = MOPT_MFILL;
  2589. X                filler = M_FILL;
  2590. X            }
  2591. X            else if( ptr->flag & M_DFILLED )
  2592. X            {
  2593. X                fills = MOPT_MFILL;
  2594. X                filler = M_FILL;
  2595. X                start = ptr->r_size;;
  2596. X            }
  2597. X            else
  2598. X            {
  2599. X                fills = 0;
  2600. X            }
  2601. X            break;
  2602. X
  2603. X        case FILL_CALLOC:
  2604. X            fills = MOPT_DFILL;
  2605. X            break;
  2606. X
  2607. X        default:
  2608. X            fills = 0;
  2609. X    }
  2610. X
  2611. X
  2612. X    if( (fills & MOPT_DFILL) != 0 )
  2613. X    {
  2614. X        if( (malloc_opts & MOPT_DFILL) != 0 )
  2615. X        {
  2616. X            ptr->s.filler[LONGFILL-1] = fillmalloc;
  2617. X            ptr->flag |= M_DFILLED;
  2618. X        }
  2619. X        else if( alloctype != FILL_FREE ) 
  2620. X        {
  2621. X            ptr->flag &= ~M_DFILLED;
  2622. X        }
  2623. X    }
  2624. X
  2625. X    if( (malloc_opts & (MOPT_MFILL|MOPT_FFILL) & fills) != 0 )
  2626. X    {
  2627. X        /*
  2628. X         * fill in the data
  2629. X         */
  2630. X        DataMS(ptr->data+start, filler, (MEMSIZE) (limit - start));
  2631. X
  2632. X        ptr->flag |= M_FILLED;
  2633. X    }
  2634. X    else 
  2635. X    {
  2636. X        ptr->flag &= ~M_FILLED;
  2637. X
  2638. X        /*
  2639. X         * if we still have to fill the boundry area and this isn't 
  2640. X         * a free-fill, go do it
  2641. X         */
  2642. X        if( ((ptr->flag & M_DFILLED) != 0) && (filler == M_FILL) )
  2643. X        {
  2644. X            DataMS(ptr->data+ptr->r_size, M_FILL, 
  2645. X                    (MEMSIZE) (limit - ptr->r_size));
  2646. X        }
  2647. X
  2648. X    }
  2649. X
  2650. X} /* FillData(... */
  2651. X
  2652. END_OF_FILE
  2653. if test 7792 -ne `wc -c <'fill.c'`; then
  2654.     echo shar: \"'fill.c'\" unpacked with wrong size!
  2655. fi
  2656. # end of 'fill.c'
  2657. fi
  2658. if test -f 'tostring.h' -a "${1}" != "-c" ; then 
  2659.   echo shar: Will not clobber existing file \"'tostring.h'\"
  2660. else
  2661. echo shar: Extracting \"'tostring.h'\" \(1170 characters\)
  2662. sed "s/^X//" >'tostring.h' <<'END_OF_FILE'
  2663. X/*
  2664. X * (c) Copyright 1990, 1991, 1992 Conor P. Cahill (cpcahil@virtech.vti.com)
  2665. X *
  2666. X * This software may be distributed freely as long as the following conditions
  2667. X * are met:
  2668. X *         * the distribution, or any derivative thereof, may not be
  2669. X *          included as part of a commercial product
  2670. X *        * full source code is provided including this copyright
  2671. X *        * there is no charge for the software itself (there may be
  2672. X *          a minimal charge for the copying or distribution effort)
  2673. X *        * this copyright notice is not modified or removed from any
  2674. X *          source file
  2675. X */
  2676. X/*
  2677. X * $Id: tostring.h,v 1.5 1992/08/22 16:27:13 cpcahil Exp $
  2678. X */
  2679. X#define B_BIN     2
  2680. X#define B_DEC    10
  2681. X#define B_HEX    16
  2682. X#define B_OCTAL     8
  2683. X
  2684. X/* 
  2685. X * $Log: tostring.h,v $
  2686. X * Revision 1.5  1992/08/22  16:27:13  cpcahil
  2687. X * final changes for pl14
  2688. X *
  2689. X * Revision 1.4  1992/04/13  03:06:33  cpcahil
  2690. X * Added Stack support, marking of non-leaks, auto-config, auto-testing
  2691. X *
  2692. X * Revision 1.3  1991/11/25  14:42:07  cpcahil
  2693. X * Final changes in preparation for patch 4 release
  2694. X *
  2695. X * Revision 1.2  90/05/11  00:13:11  cpcahil
  2696. X * added copyright statment
  2697. X * 
  2698. X * Revision 1.1  90/02/23  07:09:05  cpcahil
  2699. X * Initial revision
  2700. X * 
  2701. X */
  2702. END_OF_FILE
  2703. if test 1170 -ne `wc -c <'tostring.h'`; then
  2704.     echo shar: \"'tostring.h'\" unpacked with wrong size!
  2705. fi
  2706. # end of 'tostring.h'
  2707. fi
  2708. echo shar: End of archive 3 \(of 10\).
  2709. cp /dev/null ark3isdone
  2710. MISSING=""
  2711. for I in 1 2 3 4 5 6 7 8 9 10 ; do
  2712.     if test ! -f ark${I}isdone ; then
  2713.     MISSING="${MISSING} ${I}"
  2714.     fi
  2715. done
  2716. if test "${MISSING}" = "" ; then
  2717.     echo You have unpacked all 10 archives.
  2718.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2719. else
  2720.     echo You still need to unpack the following archives:
  2721.     echo "        " ${MISSING}
  2722. fi
  2723. ##  End of shell archive.
  2724. exit 0
  2725. *** SENTINEL(tm) The ultimate Debugging Environment - email for more info ***
  2726.  
  2727. Conor P. Cahill              (703)430-9247            cpcahil@virtech.vti.com
  2728. Virtual Technologies, Inc.  46030 Manekin Plaza          Dulles, VA 21066 
  2729.  
  2730. exit 0 # Just in case...
  2731.