[Bf-committers] fix to #2117
Alexander Ewering
blender at instinctive.de
Mon Jan 24 23:58:50 CET 2005
On Mon, 24 Jan 2005, Joilnen Batista Leite wrote:
> well,
> here is BLI_strncpy code:
>
> char *BLI_strncpy(char *dst, char *src, int maxncpy) {
> int srclen= strlen(src);
> int cpylen=
> (srclen>(maxncpy-1))?(maxncpy-1):srclen;
>
> memcpy(dst, src, cpylen);
> dst[cpylen]= '\0';
>
> return dst;
> }
> seems to return a terminated string for me.
That's very interesting.
I thought that BLI_strncpy was just a wrapper to the libc strncpy,
which definitely does not null-terminate the string if it doesn't
fit.
However, it still doesn't change the fact that the call
BLI_strncpy( self->name, name, strlen( name ) + 1 );
is fully equivalent to:
strcpy(self->name, name);
| alexander ewering instinctive mediaworks
| ae[@]instinctive[.]de http://www[.]instinctive[.]de
More information about the Bf-committers
mailing list