mirror of
https://gitlab.com/80486DX2-66/gists
synced 2024-11-09 21:32:02 +05:30
reverse-ramdisk.c: rename variable data
to src
This commit is contained in:
parent
eaf2bd306c
commit
27b4045373
@ -58,7 +58,7 @@ size_t num_temp_files = 0;
|
||||
|
||||
int tf_alloc(size_t n, size_t type_size);
|
||||
int tf_free(int ID);
|
||||
int tf_write(int ID, size_t offset, void* data, size_t data_size);
|
||||
int tf_write(int ID, size_t offset, void* src, size_t data_size);
|
||||
int tf_read(int ID, size_t offset, void* dest, size_t data_size);
|
||||
|
||||
int tf_alloc(size_t n, size_t type_size) {
|
||||
@ -154,7 +154,7 @@ int tf_free(int ID) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tf_write(int ID, size_t offset, void* data, size_t data_size) {
|
||||
int tf_write(int ID, size_t offset, void* src, size_t data_size) {
|
||||
size_t index = (size_t) ID;
|
||||
|
||||
#if IS_POSIX
|
||||
@ -180,9 +180,9 @@ int tf_write(int ID, size_t offset, void* data, size_t data_size) {
|
||||
|
||||
// Write the data to the file
|
||||
#if IS_POSIX
|
||||
ssize_t bytes_written = write(file, data, data_size);
|
||||
ssize_t bytes_written = write(file, src, data_size);
|
||||
#else
|
||||
size_t bytes_written = fwrite(data, 1, data_size, file);
|
||||
size_t bytes_written = fwrite(src, 1, data_size, file);
|
||||
#endif
|
||||
|
||||
if (
|
||||
@ -219,8 +219,8 @@ int tf_read(int ID, size_t offset, void* dest, size_t data_size) {
|
||||
return -1;
|
||||
|
||||
// Read the data from the file
|
||||
void* data = malloc(data_size);
|
||||
if (data == NULL) {
|
||||
void* src = malloc(data_size);
|
||||
if (src == NULL) {
|
||||
#if IS_POSIX
|
||||
close(file);
|
||||
#else
|
||||
@ -230,7 +230,7 @@ int tf_read(int ID, size_t offset, void* dest, size_t data_size) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(data, 0, data_size); // clear destination
|
||||
memset(src, 0, data_size); // clear destination
|
||||
// Set the position
|
||||
#if IS_POSIX
|
||||
if (lseek(file, offset, SEEK_SET) == -1) {
|
||||
@ -243,13 +243,13 @@ int tf_read(int ID, size_t offset, void* dest, size_t data_size) {
|
||||
|
||||
// read bytes
|
||||
#if IS_POSIX
|
||||
ssize_t bytes_read = read(file, data, data_size);
|
||||
ssize_t bytes_read = read(file, src, data_size);
|
||||
#else
|
||||
size_t bytes_read = fread(data, 1, data_size, file);
|
||||
size_t bytes_read = fread(src, 1, data_size, file);
|
||||
#endif
|
||||
memcpy(dest, data, data_size);
|
||||
memcpy(dest, src, data_size);
|
||||
|
||||
free(data); // Free the allocated memory
|
||||
free(src); // Free the allocated memory
|
||||
|
||||
if (
|
||||
#if IS_POSIX
|
||||
@ -261,7 +261,7 @@ int tf_read(int ID, size_t offset, void* dest, size_t data_size) {
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Read: ID = %d, data = %016" PRIXPTR ", size = %zu -> '",
|
||||
printf("Read: ID = %d, src = %016" PRIXPTR ", size = %zu -> '",
|
||||
ID, (uintptr_t)dest, data_size);
|
||||
for (size_t i = 0; i < data_size; i++)
|
||||
printf("0x%02" PRIX8 " ", *((uint8_t*)((uint8_t*)dest + i)));
|
||||
|
Loading…
Reference in New Issue
Block a user