Fix: Memory leaks#575
Fix: Memory leaks#575Piloalucard wants to merge 4 commits intoLinearTapeFileSystem:v2.4.8-windows-supportfrom
Conversation
| attr_data[2] = format; /* set data format type */ | ||
| ltfs_u16tobe(attr_data + 3, attr_size); /* set data size */ | ||
|
|
||
| data = attr_data + TC_MAM_PAGE_HEADER_SIZE; |
There was a problem hiding this comment.
Is that what you want? You are adding the header size to the pointer, an address returned by calloc, attr_data
There was a problem hiding this comment.
Yes.
Addresses are hexadecimal, integer values. Adding in this context by 1 means the address augments 1 byte as of:
- Address A = 0x09
- Address B = Null
- Address B = Address A + 1 = 0x0A
So we write starting on the first position of our given memory address, it is an offset.
We add the memory header size to start writing in the buffer after the header size, which space is being occupied by the header.
It was refactored for readability.
There was a problem hiding this comment.
Could you please add a comment to specify it? I think it does not hurt. You can use something like the explanation you gave:
// Adding the header size to start writing in the buffer after that size
Added comment to clarify data pointer adjustment for writing.
Summary of changes
This pull request includes following changes or fixes.
Type of change
Please delete items that are not relevant.
Checklist: