fiemap copy: add extent-scan.[ch], avoid a double-free and reorganize
authorjeff.liu <jeff.liu@oracle.com>
Wed, 29 Sep 2010 08:11:41 +0000 (16:11 +0800)
committerJim Meyering <meyering@redhat.com>
Sun, 30 Jan 2011 19:44:11 +0000 (20:44 +0100)
commit2db1433eabc847d9ad43e059764222e9b33233aa
tree52004fa39c3225022cbb77d501be0f3ffd309add
parentf3e78eeff292fcc79814e62d015a271688e0212a
fiemap copy: add extent-scan.[ch], avoid a double-free and reorganize

Changes:
========
1. fix write_zeros() per Jim's comments.
2. remove char const *fname from struct extent_scan.
3. change the signature of open_extent_scan() from
"void open_extent_scan(struct extent_scan **scan)" to
"void open_extent_scan(struct extent_scan *scan)" to avoid having
to malloc the extent_scan variable; instead save it on the stack.
4. move close_extent_scan() from a function defined in extent-scan.c
to extent-scan.h as a macro definition, but it does nothing for now,
since initial extent scan defined at stack.
5. add a macro "free_extents_info()" defined at extent-scan.h to
release the memory allocated to extent info which should be called
combine with get_extents_info(), it just one line, so IMHO, define
it as macro should be ok.

* src/extent-scan.c: New file; functions to read "extents".
* src/extent-scan.h: Header file of extent-scan.c.
* src/Makefile.am: Reference it and link it to copy_source.
* src/copy.c: Use the new functions and avoid double-free.
src/Makefile.am
src/copy.c
src/extent-scan.c [new file with mode: 0644]
src/extent-scan.h [new file with mode: 0644]