1
0
mirror of https://git.zap.org.au/git/trader.git synced 2024-07-21 16:14:14 -04:00

Add the restrict keyword where appropriate

This commit is contained in:
John Zaitseff 2011-07-20 21:18:49 +10:00
parent 6ee474e438
commit b3f1820418
2 changed files with 9 additions and 10 deletions

View File

@ -199,7 +199,7 @@ char *game_filename (int gamenum)
/***********************************************************************/
// err_exit: Print an error and exit
void err_exit (const char *format, ...)
void err_exit (const char *restrict format, ...)
{
va_list args;
@ -219,7 +219,7 @@ void err_exit (const char *format, ...)
/***********************************************************************/
// errno_exit: Print an error message (using errno) and exit
void errno_exit (const char *format, ...)
void errno_exit (const char *restrict format, ...)
{
va_list args;
int saved_errno = errno;
@ -399,7 +399,7 @@ ssize_t l_strfmon (char *restrict s, size_t maxsize,
/***********************************************************************/
// scramble: Scramble (encrypt) the buffer
char *scramble (int key, char *buf, int bufsize)
char *scramble (int key, char *restrict buf, int bufsize)
{
/* The algorithm used here is reversable: scramble(scramble(...))
will (or, at least, should!) return the same as the original
@ -410,9 +410,8 @@ char *scramble (int key, char *buf, int bufsize)
if (buf != NULL && key != 0) {
char *p = buf;
unsigned char k = ~key;
int i;
for (i = 0; i < bufsize && *p != '\0'; i++, k++, p++) {
for (int i = 0; i < bufsize && *p != '\0'; i++, k++, p++) {
char c = *p;
char r = c ^ k; // Simple encryption: XOR on a moving key
@ -430,7 +429,7 @@ char *scramble (int key, char *buf, int bufsize)
/***********************************************************************/
// unscramble: Unscramble (decrypt) the buffer
char *unscramble (int key, char *buf, int bufsize)
char *unscramble (int key, char *restrict buf, int bufsize)
{
return scramble(key, buf, bufsize);
}

View File

@ -142,7 +142,7 @@ extern char *game_filename (int gamenum);
with the user string as a second argument), NOT passed in as the format
itself.
*/
extern void err_exit (const char *format, ...)
extern void err_exit (const char *restrict format, ...)
__attribute__((noreturn, format (printf, 1, 2)));
@ -161,7 +161,7 @@ extern void err_exit (const char *format, ...)
colons nor the trailing end-line character. The format may be NULL if
no intermediate message is needed.
*/
extern void errno_exit (const char *format, ...)
extern void errno_exit (const char *restrict format, ...)
__attribute__((noreturn, format (printf, 1, 2)));
@ -278,7 +278,7 @@ extern ssize_t l_strfmon (char *restrict s, size_t maxsize,
and after encryption. At most bufsize bytes are encrypted; buf is
returned as the result.
*/
extern char *scramble (int key, char *buf, int bufsize);
extern char *scramble (int key, char *restrict buf, int bufsize);
/*
@ -297,7 +297,7 @@ extern char *scramble (int key, char *buf, int bufsize);
will any encrypted character map back to these values). At most
bufsize bytes are decrypted; buf is returned as the result.
*/
extern char *unscramble (int key, char *buf, int bufsize);
extern char *unscramble (int key, char *restrict buf, int bufsize);
#endif /* included_UTILS_H */