Skip to main content
added 345 characters in body
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

I have been using similar piece of code since a while.
I I have read some issues regarding treating mapped memory as a string. I am not sure about that though.
So, so I just use strndup(3) to avoid it anyway.
Its

It's often said to use fopen, fwrite and all those f* functions over read(2), write(2) etc. The reason being, these functions handle the reading and writing quite well by intermediate buffering and are quite well organised too. But in my personal opinion, dealing with files with mmap(2) generally tends to be faster, gives nice control over the data because of MAP_* flags and making a structure yourself can organise data pretty well too. These things hold true except in some cases.
Wanted

I wanted some reviews on this code and this way of working with files:

I have been using similar piece of code since a while.
I have read some issues regarding treating mapped memory as a string. I am not sure about that though.
So I just use strndup(3) to avoid it anyway.
Its often said to use fopen, fwrite and all those f* functions over read(2), write(2) etc. The reason being, these functions handle the reading and writing quite well by intermediate buffering and are quite well organised too. But in my personal opinion, dealing with files with mmap(2) generally tends to be faster, gives nice control over the data because of MAP_* flags and making a structure yourself can organise data pretty well too. These things hold true except in some cases.
Wanted some reviews on this code and this way of working with files:

I have been using similar piece of code since a while. I have read some issues regarding treating mapped memory as a string. I am not sure about that though, so I just use strndup(3) to avoid it anyway.

It's often said to use fopen, fwrite and all those f* functions over read(2), write(2) etc. The reason being, these functions handle the reading and writing quite well by intermediate buffering and are quite well organised too. But in my personal opinion, dealing with files with mmap(2) generally tends to be faster, gives nice control over the data because of MAP_* flags and making a structure yourself can organise data pretty well too. These things hold true except in some cases.

I wanted some reviews on this code and this way of working with files:

added 511 characters in body
Source Link

I have been using similar piece of code since a while.
I have read some issues regarding treating mapped memory as a string. I am not sure about that though.
So I just use strndup(3) to avoid it anyway. Wanted
Its often said to use fopen, fwrite and all those f* functions over read(2), write(2) etc. The reason being, these functions handle the reading and writing quite well by intermediate buffering and are quite well organised too. But in my personal opinion, dealing with files with mmap(2) generally tends to be faster, gives nice control over the data because of MAP_* flags and making a structure yourself can organise data pretty well too. These things hold true except in some cases.
Wanted some reviews on this code and this way of working with files:

I have been using similar piece of code since a while.
I have read some issues regarding treating mapped memory as a string. I am not sure about that though.
So I just use strndup(3) to avoid it anyway. Wanted some reviews on this code and this way of working with files:

I have been using similar piece of code since a while.
I have read some issues regarding treating mapped memory as a string. I am not sure about that though.
So I just use strndup(3) to avoid it anyway.
Its often said to use fopen, fwrite and all those f* functions over read(2), write(2) etc. The reason being, these functions handle the reading and writing quite well by intermediate buffering and are quite well organised too. But in my personal opinion, dealing with files with mmap(2) generally tends to be faster, gives nice control over the data because of MAP_* flags and making a structure yourself can organise data pretty well too. These things hold true except in some cases.
Wanted some reviews on this code and this way of working with files:

edited tags
Link
Toby Speight
  • 81.8k
  • 14
  • 101
  • 309
added 35 characters in body
Source Link
Loading
added 176 characters in body
Source Link
Loading
Tweeted twitter.com/StackCodeReview/status/1179863746900103168
added 19 characters in body
Source Link
Loading
Source Link
Loading