Skip to content

Commit

Permalink
Surpress deprecated close warning on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
finwo committed Feb 24, 2024
1 parent fba826a commit 13df785
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/palloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ extern "C" {
#define open_os _open
#define write_os _write
#define read_os _read
#define close_os _close
#define O_CREAT _O_CREAT
#define O_RDWR _O_RDWR
#define OPENMODE (_S_IREAD | _S_IWRITE)
Expand All @@ -57,6 +58,7 @@ extern "C" {
#define open_os open
#define write_os write
#define read_os read
#define close_os close
#define OPENMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)
#else
#define stat_os stat64
Expand All @@ -65,6 +67,7 @@ extern "C" {
#define open_os open
#define write_os write
#define read_os read
#define close_os close
#define OPENMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)
#endif

Expand Down Expand Up @@ -198,7 +201,7 @@ void palloc_close(struct palloc_t *pt) {
if (!pt) return;

if (pt->filename) free(pt->filename);
if (pt->descriptor >= 0) close(pt->descriptor);
if (pt->descriptor >= 0) close_os(pt->descriptor);
free(pt);
}

Expand Down
5 changes: 4 additions & 1 deletion test.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern "C" {
#define open_os _open
#define write_os _write
#define read_os _read
#define close_os _close
#define O_CREAT _O_CREAT
#define O_RDWR _O_RDWR
#define OPENMODE (_S_IREAD | _S_IWRITE)
Expand All @@ -39,6 +40,7 @@ extern "C" {
#define open_os open
#define write_os write
#define read_os read
#define close_os _close
#define OPENMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)
#else
#define stat_os stat64
Expand All @@ -47,6 +49,7 @@ extern "C" {
#define open_os open
#define write_os write
#define read_os read
#define close_os _close
#define OPENMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)
#endif

Expand Down Expand Up @@ -100,7 +103,7 @@ void test_init() {
int fd = open_os(testfile, O_RDWR);
lseek_os(fd, 0, SEEK_SET);
write(fd, z, 1024*1024);
close(fd);
close_os(fd);

// Initialize larger medium
pt = palloc_init(testfile, PALLOC_DEFAULT);
Expand Down

0 comments on commit 13df785

Please sign in to comment.