[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] Small patch
From: |
Thomas Preud'homme |
Subject: |
Re: [Tinycc-devel] Small patch |
Date: |
Thu, 31 Jan 2013 12:43:19 +0100 |
User-agent: |
KMail/1.13.7 (Linux/3.2.0-4-amd64; KDE/4.8.4; x86_64; ; ) |
Le jeudi 31 janvier 2013 12:34:27, Stephan Beal a écrit :
> On Thu, Jan 31, 2013 at 12:07 PM, Thomas Preud'homme
<address@hidden>wrote:
> > > - strcpy(buf, "__bound_");
> > > - strcat(buf, name);
> > > + snprintf(buf, sizeof(buf), "__bound_%s", name);
>
> strcpy and strcat are C89 and C99 while snprintf is only C99.
>
>
> The semantics of the above variants are not the same, are they? strcpy()
> and strcat() are both writing to the same address in buf, i.e. strcat is
> overwriting what strcpy() copied into buf. So the end result, unless i'm
> sorely mistaken, is a copy of the name with the __bound_ prefix. strncat()
> is c89, BTW.
strcat copy the second argument at the end of the string pointed at by the
first argument.
So after strcpy you'll have __bound_ and then the strcat will add name at the
end of this string.
Did I misunderstand what you said?
Best regards,
Thomas
signature.asc
Description: This is a digitally signed message part.
- [Tinycc-devel] Small patch, Ivo van Poorten, 2013/01/30
- Re: [Tinycc-devel] Small patch, Domingo Alvarez Duarte, 2013/01/30
- Re: [Tinycc-devel] Small patch, Domingo Alvarez Duarte, 2013/01/30
- Re: [Tinycc-devel] Small patch, Domingo Alvarez Duarte, 2013/01/30
- Re: [Tinycc-devel] Small patch, Domingo Alvarez Duarte, 2013/01/30
- Re: [Tinycc-devel] Small patch, Thomas Preud'homme, 2013/01/31
- Re: [Tinycc-devel] Small patch, Stephan Beal, 2013/01/31
- Re: [Tinycc-devel] Small patch,
Thomas Preud'homme <=
- Re: [Tinycc-devel] Small patch, Domingo Alvarez Duarte, 2013/01/31
- Re: [Tinycc-devel] Small patch, Domingo Alvarez Duarte, 2013/01/31
- Re: [Tinycc-devel] Small patch, Thomas Preud'homme, 2013/01/31
- Re: [Tinycc-devel] Small patch, Stephan Beal, 2013/01/31
- Re: [Tinycc-devel] Small patch, Thomas Preud'homme, 2013/01/31
- Re: [Tinycc-devel] Small patch, Thomas Preud'homme, 2013/01/31
- Re: [Tinycc-devel] Small patch, Vincent Lefevre, 2013/01/31
- Re: [Tinycc-devel] Small patch, grischka, 2013/01/31
- Re: [Tinycc-devel] Small patch, Vincent Lefevre, 2013/01/31
- Re: [Tinycc-devel] Small patch, grischka, 2013/01/31