From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32578 invoked by alias); 13 Feb 2008 11:32:09 -0000 Received: (qmail 32570 invoked by uid 22791); 13 Feb 2008 11:32:09 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 13 Feb 2008 11:31:49 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m1DBVheJ029530; Wed, 13 Feb 2008 06:31:44 -0500 Received: from [10.11.14.14] (vpn-14-14.rdu.redhat.com [10.11.14.14]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m1DBVg2W026289; Wed, 13 Feb 2008 06:31:42 -0500 Message-ID: <47B2D51D.8030008@redhat.com> Date: Wed, 13 Feb 2008 11:32:00 -0000 From: Andrew Haley User-Agent: Thunderbird 1.5.0.12 (X11/20071019) MIME-Version: 1.0 To: Robert William Fuller CC: John Love-Jensen , gcc-help@gcc.gnu.org Subject: Re: is this a valid approach to aliasing? References: <47B22A16.5040407@gmail.com> In-Reply-To: <47B22A16.5040407@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-02/txt/msg00121.txt.bz2 Robert William Fuller wrote: > John Love-Jensen wrote: >> Hi Robert, >> >> Can you just get rid of the void** for the items parameter (see below)? >> >> --Eljay >> >> #include >> >> int reallocItems( >> void* items, >> int itemSize, >> int* itemAlloc, >> int numItems, >> int newItems, >> int itemHint) >> { >> void* rcAlloc; >> int emptyItems; >> int allocItems; >> >> // for idempotence >> allocItems = *itemAlloc; >> >> // will the new entries fit? >> emptyItems = allocItems - numItems; >> >> if (newItems > emptyItems) >> { >> // allocate the number of entries needed or the hint, whichever is >> more >> allocItems = numItems + newItems; >> >> if (itemHint > allocItems) >> { >> allocItems = itemHint; >> } >> >> rcAlloc = realloc(items, allocItems * itemSize); >> >> if (rcAlloc) >> { >> *(void**)items = rcAlloc; This code is probably wrong. Make item a void** and get rid of the cast. Andrew.