home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / std / c / 2623 < prev    next >
Encoding:
Text File  |  1992-09-14  |  1.6 KB  |  39 lines

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!taumet!steve
  3. From: steve@taumet.com (Steve Clamage)
  4. Subject: Re: calloc()
  5. Message-ID: <1992Sep14.175431.10043@taumet.com>
  6. Organization: TauMetric Corporation
  7. References: <14455@goanna.cs.rmit.oz.au> <1992Sep10.180542.1009@taumet.com> <1992Sep13.142340.24107@druid.uucp>
  8. Date: Mon, 14 Sep 1992 17:54:31 GMT
  9. Lines: 28
  10.  
  11. darcy@druid.uucp (D'Arcy J.M. Cain) writes:
  12.  
  13. >steve@taumet.com (Steve Clamage) writes:
  14. >>That said, suppose we have a system where int and size_t are 16 bits,
  15. >>but it is possible to allocate an object bigger than 64K.  A
  16.  
  17. >But isn't size_t guaranteed to be big enough to specify any object?  It
  18. >is stated in a kind of roundabout way in the standard (you have to follow
  19. >up sizeof) but I don't think there is any doubt that if an object can be
  20. >larger than 64K then size_t must reflect this.
  21.  
  22. size_t is the type returned by the sizeof operator.  I believe you
  23. must be able to apply sizeof to any object you can declare.  Suppose
  24. ints and size_t are each 16 bits, and the compiler rejects any attempt
  25. to declare an object greater than 64K:
  26.     int big    [32767];    /* OK */
  27.     int bigger [32769];    /* ERROR: too big */
  28. This could be a conforming implementation.
  29.  
  30. Now suppose that the implementor wants to allow access to extra
  31. memory when it is available, and allows calls like
  32.     calloc(1024, 100)    /* 100K allocation */
  33. for example.  I don't think this violates any rules.  You can't
  34. use sizeof to find the size of a dynamically allocated region.
  35. -- 
  36.  
  37. Steve Clamage, TauMetric Corp, steve@taumet.com
  38. Vice Chair, ANSI C++ Committee, X3J16
  39.