Path: utzoo!attcan!uunet!husc6!bloom-beacon!tut.cis.ohio-state.edu!mandrill!hal!ncoast!allbery From: allbery@ncoast.UUCP (Brandon S. Allbery) Newsgroups: comp.unix.wizards Subject: Re: Implementation of alloca() and friends Message-ID: <8157@ncoast.UUCP> Date: 17 Jun 88 23:39:32 GMT References: <16072@brl-adm.ARPA> Reply-To: allbery@ncoast.UUCP (Brandon S. Allbery) Followup-To: comp.unix.wizards Organization: Cleveland Public Access UN*X, Cleveland, Oh Lines: 25 As quoted from <16072@brl-adm.ARPA> by enag@ifi.uio.no on dynamic arrays: +--------------- | Doesn't this look very clumsy to do in such a neat language as C? | Having to remember dimensions and their individual sizes (even opening | up for bounds checking - shock horror! :-), and building nasty access | poly(g)nomes requiring lots of CPU time even for tiny little two- | dimensional matrices... It sounds Wrong to me. Also, the bugs that | will appear because people forget to pass along the dimensions of their | conformant arrays -- leading all the way to sending a pointer to an | array descriptor structure, slowing down all the code we're so proud | of. +--------------- Why not allocate matrix[n][m] by allocating an array[n], then set each element to a pointer to an array[m]? This makes the [] operator work exactly the way it does everywhere else: x[n] == *(x + n) without having to do hairy calculations to access an element of an n-dimensional matrix. No more likely to have bounds checking than any other part of C. ;-) ++Brandon -- Brandon S. Allbery | "Given its constituency, the only uunet!marque,sun!mandrill}!ncoast!allbery | thing I expect to be "open" about Delphi: ALLBERY MCI Mail: BALLBERY | [the Open Software Foundation] is comp.sources.misc: ncoast!sources-misc | its mouth." --John Gilmore