Tighten string helper prototypes and quiet pointer-sign warnings

This commit is contained in:
Mario Fetka
2026-04-20 23:39:42 +02:00
parent f0bfd5a641
commit 33d1da469a
5 changed files with 26 additions and 26 deletions

View File

@@ -127,24 +127,24 @@ void x_x_xfree(char **p)
}
}
int strmaxcpy(uint8 *dest, uint8 *source, int len)
int strmaxcpy(uint8 *dest, const char *source, int len)
/* dest must be 1 byte larger than len */
{
int slen = (source != (uint8 *)NULL) ? min(len, strlen((char*)source)) : 0;
int slen = (source != (const char *)NULL) ? min(len, strlen(source)) : 0;
if (slen)
memcpy(dest, source, slen);
dest[slen] = '\0';
return(slen);
}
int x_x_xnewstr(uint8 **p, uint8 *s)
int x_x_xnewstr(uint8 **p, const char *s)
{
int len = (s == NULL) ? 0 : strlen((char*)s);
int len = (s == NULL) ? 0 : strlen(s);
if (*p != (uint8 *)NULL)
free((char*)*p);
*p = (uint8*)xmalloc(len+1);
if (len)
strcpy((char*)(*p), (char*)s);
strcpy((char*)(*p), s);
else
**p = '\0';
return (len);