ruknez 5 years ago
parent
commit
be461ddc9d
1 changed files with 7 additions and 7 deletions
  1. 7 7
      mmap-read.C

+ 7 - 7
mmap-read.C

@@ -34,23 +34,23 @@ int main (int argc, char* const argv[]) {
 	// lseek (fd, 0, SEEK_SET);
 
 	/* Создаем отображение в памяти. */
-//	file_memory = (char*) mmap (0, statbuf.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
-	file_memory = (char*) mmap (0, FILE_LENGTH , PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+	file_memory = (char*) mmap (0, statbuf.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+//	file_memory = (char*) mmap (0, FILE_LENGTH , PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
 
 	close (fd);
 
 //	printf ("size = %d \n", &statbuf.st_size);
 //	return 0;
+	
 	int b;
 	// char b = 0;
-	
-	for (int i = 0; i < FILE_LENGTH; i+= 0x4 ) {
+	for (int i = 0; i < statbuf.st_size; i += 4010 ) {
 
-		b = file_memory [4];
+		b = *(int *) &file_memory [i];
 
-		printf ("I am hear \n i =  %i \n", &i);
+		printf ("I am hear \n i =  %i \n", i);
 		// scanf (file_memory, "%d", &b);
-		printf ("b = %d \n", &b);
+		printf ("b = %d \n", b);
 	}
 
 	/* Освобождаем память. */