Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: A glitch regarding the usual malloc() idiom Date: Wed, 27 Jul 2016 09:14:34 -0700 Organization: None to speak of Lines: 29 Message-ID: References: <4cd22745-22ad-4ac7-bdba-39ffa1c75e13@googlegroups.com> <7d995799-5f23-4784-a62e-ea423de00650@googlegroups.com> <36f1e05e-609e-4e0e-8819-86feee1f4d8c@googlegroups.com> <57933a73.4812875@news.xs4all.nl> <5793c8e5.2941812@news.xs4all.nl> <5798cad0.2436140@news.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="19733"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/5eXMGiBbvHAG3mFe5eU0T" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:c21XDLSdi/BGlOesriwiir9bNgk= sha1:vMu+No4M+WYf3J11hM+nVcy8kVI= Xref: csiph.com comp.lang.c:91151 raltbos@xs4all.nl (Richard Bos) writes: > Malcolm McLean wrote: [...] >> magptr = malloc(40 * sizeof(int)) >> >> means allocate 160 bytes and assign to magptr. > > No, it doesn't. > >> Which almost always will be a buffer of 40 ints. > > The above is _always_ a buffer of 40 ints, not [almost] always. It > _may_ be 160 bytes. If you need (I inserted a missing "almost" in the above.) I think Malcolm is using his own idiosyncratic meaning of the word "buffer". I can't be bothered to remember what it is, but I suspect that given his definition, the malloc() call (if successful!) may or may not create a "buffer". (At least "buffer" isn't a word defined by the standard.) [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"