diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dirent.c | 56 | ||||
-rw-r--r-- | src/dirent.h | 3 |
2 files changed, 6 insertions, 53 deletions
diff --git a/src/dirent.c b/src/dirent.c index eb92a2b..0fa3156 100644 --- a/src/dirent.c +++ b/src/dirent.c @@ -33,12 +33,18 @@ _opkg_opk_dirent_name_prefix(struct opkg_opk_dirent *dirent, char **name_buf, len = strlen(dirent->name); if (*name_len + len <= *name_buf_len) { buf = name_buf; + if (*buf == NULL) { + return OPKG_OPK_ERROR; + } if (**buf != '\0') { ++len; } *name_buf_len -= len; } else if (*pref_len + len <= *pref_buf_len) { buf = pref_buf; + if (*buf == NULL) { + return OPKG_OPK_ERROR; + } if (**buf != '\0') { ++len; } @@ -83,53 +89,3 @@ opkg_opk_dirent_name_prefix(struct opkg_opk_dirent *dirent, char *name_buf, pref_buf[pref_len] = '\0'; return OPKG_OPK_OK; } - -static char * -_opkg_opk_dirent_full_name(struct opkg_opk_dirent *dirent, char **cur, - size_t *buf_len) -{ - size_t len; - char *buf; - - len = strlen(dirent->name); - if (dirent->parent != NULL) { - ++len; - } - *buf_len += len; - - if (dirent->parent == NULL) { - buf = malloc(*buf_len); - if (buf == NULL) { - return NULL; - } - *cur = buf; - } else if ((buf = _opkg_opk_dirent_full_name(dirent->parent, cur, - buf_len)) == NULL) { - return NULL; - } - - if (dirent->parent != NULL) { - **cur = '/'; - *cur += 1; - --len; - } - memcpy(*cur, dirent->name, len); - *cur += len; - - return buf; -} - -char * -opkg_opk_dirent_full_name(struct opkg_opk_dirent *dirent) -{ - char *name; - char *cur = NULL; - size_t buf_len = 1; /* 1 for NUL */ - - if ((name = _opkg_opk_dirent_full_name(dirent, &cur, &buf_len)) == NULL) - { - return NULL; - } - *cur = '\0'; - return name; -} diff --git a/src/dirent.h b/src/dirent.h index 44d33ea..4cce24f 100644 --- a/src/dirent.h +++ b/src/dirent.h @@ -29,7 +29,4 @@ int opkg_opk_dirent_name_prefix(struct opkg_opk_dirent *dirent, char *name_buf, size_t name_len, char *pref_buf, size_t pref_len); -char * -opkg_opk_dirent_full_name(struct opkg_opk_dirent *dirent); - #endif /* OPKG_OPK_DIRENT_H_ */ |