From 052e06fd16f5ef161a10fc7880e32827c814bea2 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Thu, 28 Jul 2022 19:54:25 -0300 Subject: index: rename typedef `index` to `index_t` This had to be done because `index()` is a function in the standard library. --- git.c | 4 ++-- index.c | 18 +++++++++--------- index.h | 12 ++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/git.c b/git.c index be54aa9..e13b787 100644 --- a/git.c +++ b/git.c @@ -281,7 +281,7 @@ static int parse_info_file_path(pull_request *pr, const char *root) { return ret; } -pull_request *get_pull_request(index *idx, const char *root) { +pull_request *get_pull_request(index_t *idx, const char *root) { /* Do we have a valid index? */ if (is_valid_index(idx)) { char *pr_dir; @@ -519,7 +519,7 @@ file **get_branch_commits(git_branch *br) { return NULL; } -int create_pull_request_dir(pull_request *pr, index *idx, const char *root) { +int create_pull_request_dir(pull_request *pr, index_t *idx, const char *root) { int ret = 0; struct stat st; file **commits; diff --git a/index.c b/index.c index af65925..2ea8971 100644 --- a/index.c +++ b/index.c @@ -5,10 +5,10 @@ #include "index.h" #include "macros.h" -static int index_strlen(index *idx) { +static int index_strlen(index_t *idx) { int len = 0; /* Get the length of the index. */ - for (index *i = idx; i != NULL; i = i->next) { + for (index_t *i = idx; i != NULL; i = i->next) { const int is_last = (i->next == NULL); const char *fmt = (i->type) "%llu" : "%s"; len += format_len(fmt, (i->type) ? i->num : i->name) + !is_last; @@ -16,7 +16,7 @@ static int index_strlen(index *idx) { return len; } -int is_valid_index(index *idx) { +int is_valid_index(index_t *idx) { int did_alloc = 0; char *err_str = NULL; @@ -50,7 +50,7 @@ int is_valid_index(index *idx) { return 1; } -char *make_index_path(const char *root, index *idx, int path_type) { +char *make_index_path(const char *root, index_t *idx, int path_type) { char *path; char *tmp; int path_len = strlen(root) + 1; @@ -60,7 +60,7 @@ char *make_index_path(const char *root, index *idx, int path_type) { } /* Get the length of the path. */ - for (index *i = idx; i != NULL; i = i->next) { + for (index_t *i = idx; i != NULL; i = i->next) { const int is_last = (i->next == NULL); const char *fmt = (i->type) "%llu" : "%s"; path_len += format_len(fmt, (i->type) ? i->num : i->name) + !is_last; @@ -71,7 +71,7 @@ char *make_index_path(const char *root, index *idx, int path_type) { /* Create the path. */ tmp += sprintf(tmp, "%s/", root); - for (index *i = idx; i != NULL; i = i->next) { + for (index_t *i = idx; i != NULL; i = i->next) { const int is_last = (i->next == NULL); const char *delm = (path_type) ? "-" : "/"; const char *fmt = (i->type) "%llu%s" : "%s%s"; @@ -81,12 +81,12 @@ char *make_index_path(const char *root, index *idx, int path_type) { return path; } -char *index_to_str(index *idx) { +char *index_to_str(index_t *idx) { if (is_valid_index(idx)) { char *idx_str = calloc(index_strlen(idx)+1, sizeof(char)); char *tmp = idx_str; /* Create the index. */ - for (index *i = idx; i != NULL; i = i->next) { + for (index_t *i = idx; i != NULL; i = i->next) { const int is_last = (i->next == NULL); const char *fmt = (i->type) "%llu%s" : "%s%s"; @@ -98,7 +98,7 @@ char *index_to_str(index *idx) { } } -int index_path_exists(index *idx, const char *root, char **path) { +int index_path_exists(index_t *idx, const char *root, char **path) { char *dummy; path = (path != NULL) ? path : &dummy; for (int i = 0; i < 2; ++i) { diff --git a/index.h b/index.h index 4b37534..e640514 100644 --- a/index.h +++ b/index.h @@ -3,7 +3,7 @@ #include -typedef struct index index; +typedef struct index index_t; struct index { uint8_t type; /* Index type. (0 = Named index, 1 = Numbered index) */ @@ -11,12 +11,12 @@ struct index { char *name; /* Named index. */ uint64_t num; /* Numbered index. */ }; - index *next; /* Next index. */ + index_t *next; /* Next index. */ }; -extern int is_valid_index(index *idx); -extern char *make_index_path(const char *root, index *idx, int path_type); -extern char *index_to_str(index *idx); -extern int index_path_exists(index *idx, const char *root, char **path); +extern int is_valid_index(index_t *idx); +extern char *make_index_path(const char *root, index_t *idx, int path_type); +extern char *index_to_str(index_t *idx); +extern int index_path_exists(index_t *idx, const char *root, char **path); #endif -- cgit v1.2.3-13-gbd6f