Deutsch   English   Français   Italiano  
<yK-cnTtFMYNFVFz7nZ2dnZfqnPudnZ2d@brightview.co.uk>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!local-3.nntp.ord.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail
NNTP-Posting-Date: Sun, 18 Aug 2024 10:15:52 +0000
From: Mark Summerfield <mark@qtrac.eu>
Subject: Re: size_t best practice
Newsgroups: comp.lang.c
References: <VdCcne2MOeshN1z7nZ2dnZfqnPWdnZ2d@brightview.co.uk>
	<slrnvc3cnk.obv.ike@iceland.freeshell.org>
MIME-Version: 1.0
User-Agent: Pan/0.149 (Bellevue; 4c157ba)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-ID: <yK-cnTtFMYNFVFz7nZ2dnZfqnPudnZ2d@brightview.co.uk>
Date: Sun, 18 Aug 2024 10:15:52 +0000
Lines: 19
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-L2RcoZyTGnibfC15C/naFGLjbw+GIt0AsjPIytQqtlzjFVjcdasyDpgueAG0XUAA4sdhqSLDVykHmV2!W8EQynr14IV3Zq7OSPXUmz6JLetMAQCHRPTF5Tdi87kIC2V881q5FDmZBMQwNoqKvUmB8tw/hySc!CVgGqKBgTHy27+B83Ss7DWKmmw==
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
Bytes: 1597

On Sun, 18 Aug 2024 08:38:13 -0000 (UTC), Ike Naar wrote:
[snip]
> Substitution: j = i + 1
> 
>     for (size_t j = v->_size; j > index; --j) {
>         v->_values[j] = v->_values[j - 1];
>     }

Thanks, that works great.

And as per "Michael S" I checked the man pages:

ptrdiff_t Used for a count of elements, and array indices. C99 and POSIX.1-2001.

size_t Used for a count of bytes. C99 and POSIX.1-2001.

ssize_t Used for a count of bytes or an error indication. POSIX.1-2001.

So for my arrays and loops I'll change to ptrdiff_t.