Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file: use the generic constructurs/destructors for open and close #235

Merged
merged 1 commit into from
May 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 3 additions & 23 deletions libsqsh/src/file/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,23 +188,8 @@ sqsh__file_init(
}

struct SqshFile *
sqsh_open_by_ref(struct SqshArchive *sqsh, uint64_t inode_ref, int *err) {
int rv = 0;
struct SqshFile *inode = calloc(1, sizeof(struct SqshFile));
if (inode == NULL) {
rv = -SQSH_ERROR_MALLOC_FAILED;
goto out;
}
rv = sqsh__file_init(inode, sqsh, inode_ref);
if (rv < 0) {
free(inode);
inode = NULL;
}
out:
if (err != NULL) {
*err = rv;
}
return inode;
sqsh_open_by_ref(struct SqshArchive *archive, uint64_t inode_ref, int *err) {
SQSH_NEW_IMPL(sqsh__file_init, struct SqshFile, archive, inode_ref);
}

bool
Expand Down Expand Up @@ -416,10 +401,5 @@ sqsh_open(struct SqshArchive *archive, const char *path, int *err) {

int
sqsh_close(struct SqshFile *file) {
if (file == NULL) {
return 0;
}
int rv = sqsh__file_cleanup(file);
free(file);
return rv;
SQSH_FREE_IMPL(sqsh__file_cleanup, file);
}
Loading