home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / stdlib / Mem_SetTraceSizes.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-22  |  1.9 KB  |  70 lines

  1. /* 
  2.  * Mem_SetTraceSizes.c --
  3.  *
  4.  *    Source code for the "Mem_SetTraceSizes" library procedure.  See
  5.  *    memInt.h for overall information about how the allocator works.
  6.  *
  7.  * Copyright 1988 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /sprite/src/lib/c/stdlib/RCS/Mem_SetTraceSizes.c,v 1.1 88/05/20 15:49:26 ouster Exp $ SPRITE (Berkeley)";
  19. #endif not lint
  20.  
  21. #include "memInt.h"
  22.  
  23. /*
  24.  *----------------------------------------------------------------------
  25.  *
  26.  * Mem_SetTraceSizes --
  27.  *
  28.  *    Defines a list of sizes to trace and causes tracing to start.
  29.  *    If the numSizes is zero or the array ptr is NULL, tracing is
  30.  *    turned off.
  31.  *
  32.  * Results:
  33.  *    None.
  34.  *
  35.  * Side effects:
  36.  *    Traces of Mem_Alloc and Mem_Free start or end.
  37.  *
  38.  *----------------------------------------------------------------------
  39.  */
  40. ENTRY void
  41. Mem_SetTraceSizes(numSizes, arrayPtr)
  42.     int          numSizes;        /* # of elements in arrayPtr */
  43.     Mem_TraceInfo *arrayPtr;        /* Array of block sizes to trace. */
  44. {
  45.     int    i;
  46.  
  47.     LOCK_MONITOR;
  48.  
  49.     if (numSizes <= 0 || (arrayPtr == (Mem_TraceInfo *) NULL) 
  50.         || arrayPtr == (Mem_TraceInfo *)NULL) {
  51.     if (numSizes == -1) {
  52.         memNumSizesToTrace = -1;
  53.     } else {
  54.         memNumSizesToTrace = 0;
  55.     }
  56.     UNLOCK_MONITOR;
  57.     return;
  58.     }  
  59.  
  60.     if (numSizes > MAX_NUM_TRACE_SIZES) {
  61.     numSizes = MAX_NUM_TRACE_SIZES;
  62.     }
  63.     memNumSizesToTrace = numSizes;
  64.     for (i = 0; i < numSizes; i++) {
  65.     memTraceArray[i].traceInfo = arrayPtr[i];
  66.     memTraceArray[i].traceInfo.flags |= MEM_TRACE_NOT_INIT;
  67.     }
  68.     UNLOCK_MONITOR;
  69. }
  70.