Merging sparse chunk can make sparse map block bigger than 4GiB,
that can't be covered by unsigned integer type. Fix this by
changing unsigned int to uint64_t type.
Test: sparse build
Bug: 162808120
Change-Id: Id4d3f88f9d531c25c3937c99b2c81efb915605ee
Signed-off-by: Hyeongseok Kim <hyeongseok@gmail.com>
Cc: hyeongseok.kim <hyeongseok.kim@lge.com>
Fix memory leak in output_file_close():
Arguable whose resposibility to free structs allocated inside a file
struct (the caller or the library function), but the following protocol
(i.e. this fix) would better prevent memory leaks:
1) output_file_close() function will free those structs inside a file struct,
right before closing the file.
* Note: those structs are originally allocated by other libsparse function.
2) If the caller wants to clean up those struct inside a file struct,
it may. Just free those structs, and set the pointer to NULL.
Afterward, when file_close()'s are called, they won't be free'ed twice.
Bug: 142483439
Test: verified by script MemLeak_LastCmd.sh (attached in Bugnizer)
Change-Id: I8bb9f7c9f7d19268663e2830d1a90d27bd5f99bd
Signed-off-by: Robin Hsu <robinhsu@google.com>
this makes libsparse compile with MacOS clang++
Test: "libsparse" compiles and works fine under both Linux and MacOS
Change-Id: Ifcf018b856d2fe5f1dac7eeddd72de2810be66c5
This reverts commit db69f0d47f.
Reason for revert: Broke the build:
In file included from system/core/libsparse/sparse.cpp:26:
system/core/libsparse/output_file.h:34:72: error: unknown type name 'off64_t'; did you mean 'off_t'?
int (*skip_write)(void*, off64_t), void* priv,
^~~~~~~
off_t
/Applications/Xcode6.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/_types/_off_t.h:30:25: note: 'off_t' declared here
typedef __darwin_off_t off_t;
^
1 error generated.
Bug: 78793464
Change-Id: I0f8bc4e9aa2f74612bfd8721d00d961e3f7e695f
Currently, sparse_file_callback uses libsparse's
own logic for reading a file into a buffer. However,
a caller may want to use their own logic for doing
this in order to customize the buffer size and parallelize
the reads/writes. Also, a caller may want to implement
fill blocks with their own logic as well. To do this
add sparse_file_typed_callback which calls a different
callback function depending on the type of the sparse
chunk being written.
Test: Use typed callback for fd writes
Bug: 78793464
Change-Id: I75955a464fc05991f806339830fdfa05fda354b9