Commit 5d9d3029 authored by Sergej Chodarev's avatar Sergej Chodarev
Browse files

Use named constant for like_count_text buffer size

parent 99c92aad
...@@ -9,7 +9,7 @@ void empty_input_buffer() { ...@@ -9,7 +9,7 @@ void empty_input_buffer() {
} }
void show_wall_ui(wall_t *wall) { void show_wall_ui(wall_t *wall) {
char buf[30]; char buf[LIKE_COUNT_BUFFER_SIZE];
post_t *post; post_t *post;
for (int i = 1; i <= wall->num_posts; i++) { for (int i = 1; i <= wall->num_posts; i++) {
......
...@@ -32,7 +32,7 @@ void unlike_post(post_t *post) { ...@@ -32,7 +32,7 @@ void unlike_post(post_t *post) {
* singular/plural forms into account. * singular/plural forms into account.
* *
* post - the post of interest * post - the post of interest
* buf - a buffer at least 30 bytes long (if int is 64-bit) * buf - a buffer at least LIKE_COUNT_BUFFER_SIZE bytes long
* *
* This function is intentionally awful - it is a candidate for refactoring. * This function is intentionally awful - it is a candidate for refactoring.
*/ */
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#define POST_H #define POST_H
#define MAX_POST_LENGTH 30 #define MAX_POST_LENGTH 30
/* Space for two 64-bit integers and additional text */
#define LIKE_COUNT_BUFFER_SIZE 60
typedef struct { typedef struct {
char text[MAX_POST_LENGTH + 1]; char text[MAX_POST_LENGTH + 1];
......
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