Commit d4b75e75 authored by TheLostWanderer's avatar TheLostWanderer
Browse files

add const keyword on const var

parent 4537c3b6
......@@ -9,12 +9,12 @@ typedef struct s_communication
} t_communication;
void print_msg(char *talker, char *chat);
void print_msg(const char *talker, const char *chat);
void write_message(int sock, char *message);
void write_message(const int sock, const char *message);
char *read_message(int sock, char *message);
char *read_message(const int sock, char *message);
#endif
......@@ -24,7 +24,7 @@ void print_msg(const char *talker, const char *chat)
fflush(stdout);
}
void write_message(int sock, const char *message)
void write_message(const int sock, const char *message)
{
int loglen = strlen(message);
int n;
......@@ -36,7 +36,7 @@ void write_message(int sock, const char *message)
error("ERROR writing to socket");
}
char *read_message(int sock, char *message)
char *read_message(const int sock, char *message)
{
int loglen;
int n;
......@@ -49,13 +49,13 @@ char *read_message(int sock, char *message)
printf("DEBUG: Size msg: %d\n", loglen);
#endif
message = realloc(message, sizeof(char) * (loglen + 1));
message = realloc(message, loglen + 1);
if (message == NULL)
return (NULL);
// Receive the message
n = read(sock, message, loglen);
if (n<0)
if ( n < 0 )
error("ERROR reading from socket");
// Remove \n character at the end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment