diff --git a/c-programming/reverse-ramdisk.c b/c-programming/reverse-ramdisk.c index ba78179..50e1eb4 100644 --- a/c-programming/reverse-ramdisk.c +++ b/c-programming/reverse-ramdisk.c @@ -19,6 +19,19 @@ To-Do: error handling on line 167, function fread() #include #include +#ifdef DEBUG +# define line_fail(x) do { \ + printf("failed on line %d\n", __LINE__ + x); \ +} while (0) +#else +# define line_fail(x) do {} while (0) +#endif + +#define retreat(s) do { \ + perror(s); \ + exit(EXIT_FAILURE); \ +} while (0) + typedef struct { int ID; char* file_path; @@ -33,14 +46,6 @@ int tf_free(int ID); int tf_write(int ID, size_t offset, void* data, size_t data_size); int tf_read(int ID, size_t offset, void* dest, size_t data_size); -#ifdef DEBUG -# define line_fail(x) do { \ - printf("failed on line %d\n", __LINE__ + x); \ -} while (0) -#else -# define line_fail(x) do {} while (0) -#endif - int tf_alloc(size_t n, size_t type_size) { // Create an empty file size_t len_digit; @@ -190,11 +195,6 @@ int tf_read(int ID, size_t offset, void* dest, size_t data_size) { return 0; } -#define retreat(s) do { \ - perror(s); \ - exit(EXIT_FAILURE); \ -} while (0) - #ifdef TEST int main(void) { int ID = tf_alloc(4, sizeof(int));