home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1156 / dynP.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-28  |  1.3 KB  |  49 lines

  1. /*
  2.  * This file is part of libdyn.a, the C Dynamic Object library.  It
  3.  * contains the private header file.
  4.  *
  5.  * There are no restrictions on this code; however, if you make any
  6.  * changes, I request that you document them so that I do not get
  7.  * credit or blame for your modifications.
  8.  *
  9.  * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
  10.  * and MIT-Project Athena, 1989.
  11.  */
  12.  
  13.  
  14. /*
  15.  * dynP.h -- private header file included by source files for libdyn.a.
  16.  */
  17.  
  18. #ifndef _DynP_h
  19. #define _DynP_h
  20.  
  21. #include "dyn.h"
  22.  
  23. /*
  24.  * Rep invariant:
  25.  * 1) el_size is the number of bytes per element in the object
  26.  * 2) num_el is the number of elements currently in the object.  It is
  27.  * one higher than the highest index at which an element lives.
  28.  * 3) size is the number of elements the object can hold without
  29.  * resizing.  num_el <= index.
  30.  * 4) inc is a multiple of the number of elements the object grows by
  31.  * each time it is reallocated.
  32.  */
  33.  
  34. typedef struct _DynObject {
  35.      DynPtr    array;
  36.      int    el_size, num_el, size, inc;
  37.      char    debug, paranoid;
  38. } DynObjectRecP, *DynObjectP;
  39.  
  40. /* Internal functions */
  41. int _DynRealloc();
  42.  
  43. #define _DynResize(obj, req) \
  44.      ((obj)->size > (req) ? DYN_OK : \
  45.      (_DynRealloc((obj), (((req) - (obj)->size) / (obj)->inc) + 1)))
  46.  
  47. #endif /* _DynP_h */
  48. /* DON'T ADD STUFF AFTER THIS #endif */
  49.