Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #9295

Re: Hash table implementation.

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Hash table implementation.
Date 2011-08-12 14:08 -0700
Organization None to speak of
Message-ID <ln62m272y6.fsf@nuthaus.mib.org> (permalink)
References (5 earlier) <lnr54q7i8g.fsf@nuthaus.mib.org> <86e507c7-f1ad-475b-bc49-a164ed5ff7da@y24g2000yqb.googlegroups.com> <4E4568B9.5030306@verizon.net> <b6945044-43f3-4b99-8be1-c398bb1c1d55@z7g2000vbp.googlegroups.com> <slrnj4b3ks.1og7.usenet-nospam@guild.seebs.net>

Show all headers | View raw


Seebs <usenet-nospam@seebs.net> writes:
> On 2011-08-12, tom st denis <tom@iahu.ca> wrote:
>> It's portable that in if you were born after the fall of the wall, and
>> develop software used on machines after the fall of indoor smoking at
>> shopping centres ... chances are highly good that you're on a machine
>> with[out] a MMU where there are no tag bits, no funkyness, and
>> pointers are just 16, 32, and/or 64 bit words where NULL is just all
>> zeroes.
>
> Chances are good, yes, but...
>
> There are reasons, even on such hardware, to prefer some non-all-bits-zero
> pointer as "null".

I've worked on a system where a null pointer has the value 1, because
the CPU trapped on word access to odd addresses.  It was Pascal, not C,
but the same thing could apply to a C implementation.

On the other hand, modern systems are more likely to do this by
unmapping the appropriate address range (as I recall the system didn't
have virtual memory).

>> ISO C would do well by just dropping such nonsense...
>
> I don't think so.  I honestly think we would all probably be better off
> if most modern systems had used 0xFFFFFFFF (or more Fs on 64-bit) as the
> C "NULL".

We don't know what seemingly odd decisions might be made for future
architectures.  A lot of code had to be re-written when some system
started trapping on references to address 0; prior to that, *(char*)0
would quietly give you 0, and a lot of software took advantage of that.

Avoiding undefined behavior in C can make your code portable both to
systems that are so old that you've never heard of them, and to systems
that haven't been invented yet.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Hash table implementation. lolzy@live.nl - 2011-08-11 10:43 -0700
  Re: Hash table implementation. China Blue Tip Wrench <chine.bleu@yahoo.com> - 2011-08-11 11:25 -0700
  Re: Hash table implementation. Keith Thompson <kst-u@mib.org> - 2011-08-11 11:49 -0700
    Re: Hash table implementation. Ralf Damaschke <rwspam@gmx.de> - 2011-08-11 20:02 +0000
  Re: Hash table implementation. Ike Naar <ike@sverige.freeshell.org> - 2011-08-11 22:02 +0000
  Re: Hash table implementation. "Scott Fluhrer" <sfluhrer@ix.netcom.com> - 2011-08-11 18:14 -0400
    Re: Hash table implementation. lolzy@live.nl - 2011-08-11 23:55 -0700
      Re: Hash table implementation. lolzy@live.nl - 2011-08-12 01:38 -0700
      Re: Hash table implementation. Nobody <nobody@nowhere.com> - 2011-08-12 09:47 +0100
        Re: Hash table implementation. tom st denis <tom@iahu.ca> - 2011-08-12 06:15 -0700
          Re: Hash table implementation. James Kuyper <jameskuyper@verizon.net> - 2011-08-12 11:34 -0400
            Re: Hash table implementation. Keith Thompson <kst-u@mib.org> - 2011-08-12 08:50 -0700
              Re: Hash table implementation. James Kuyper <jameskuyper@verizon.net> - 2011-08-12 12:24 -0400
          Re: Hash table implementation. Keith Thompson <kst-u@mib.org> - 2011-08-12 08:38 -0700
            Re: Hash table implementation. tom st denis <tom@iahu.ca> - 2011-08-12 10:17 -0700
              Re: Hash table implementation. James Kuyper <jameskuyper@verizon.net> - 2011-08-12 13:54 -0400
                Re: Hash table implementation. tom st denis <tom@iahu.ca> - 2011-08-12 11:30 -0700
                Re: Hash table implementation. Seebs <usenet-nospam@seebs.net> - 2011-08-12 20:39 +0000
                Re: Hash table implementation. Keith Thompson <kst-u@mib.org> - 2011-08-12 14:08 -0700
            Re: Hash table implementation. gordonb.4sxmx@burditt.org (Gordon Burditt) - 2011-08-12 20:04 -0500
              Re: Hash table implementation. Keith Thompson <kst-u@mib.org> - 2011-08-12 18:40 -0700
                Re: Hash table implementation. Harald van Dijk <truedfx@gmail.com> - 2011-08-13 12:59 -0700
              Re: Hash table implementation. Seebs <usenet-nospam@seebs.net> - 2011-08-13 02:34 +0000
      Re: Hash table implementation. Ike Naar <ike@iceland.freeshell.org> - 2011-08-12 11:13 +0000
      Re: Hash table implementation. Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-08-12 07:24 -0400
      Re: Hash table implementation. Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-08-12 09:27 -0600
      Re: Hash table implementation. Seebs <usenet-nospam@seebs.net> - 2011-08-12 18:37 +0000
      Re: Hash table implementation. Jens Gustedt <Jens.Gustedt@loria.fr> - 2011-08-13 00:08 +0200
        Re: Hash table implementation. Keith Thompson <kst-u@mib.org> - 2011-08-12 15:26 -0700
          Re: Hash table implementation. Jens Gustedt <Jens.Gustedt@loria.fr> - 2011-08-13 15:11 +0200
            Re: Hash table implementation. Keith Thompson <kst-u@mib.org> - 2011-08-13 11:38 -0700
              Re: Hash table implementation. Jens Gustedt <Jens.Gustedt@loria.fr> - 2011-08-13 21:03 +0200
        Re: Hash table implementation. "Herbert Rosenau" <os2guy@pc-rosenau.de> - 2011-08-19 08:17 +0000
          Re: Hash table implementation. Jens Gustedt <jens.gustedt@loria.fr> - 2011-08-19 13:29 +0200
          Re: Hash table implementation. Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-08-19 14:35 +0300
  Re: Hash table implementation. Michael Angelo Ravera <maravera@prodigy.net> - 2011-08-12 02:54 -0700
  Re: Hash table implementation. Rui Maciel <rui.maciel@gmail.com> - 2011-08-13 23:11 +0100
    Re: Hash table implementation. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-08-14 00:56 +0100
      Re: Hash table implementation. lolzy@live.nl - 2011-08-14 00:11 -0700
        Re: Hash table implementation. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-08-14 11:57 +0100

csiph-web