Module: wine Branch: master Commit: c479ea631ff9a23a43e9262cbebcb170ba9443b2 URL: http://source.winehq.org/git/wine.git/?a=commit;h=c479ea631ff9a23a43e9262cbe...
Author: Juan Lang juan.lang@gmail.com Date: Wed Aug 6 14:09:39 2008 -0700
cabinet: Use helper function to remove duplicate code.
---
dlls/cabinet/fdi.c | 90 ++++++++++++++++++++------------------------------- 1 files changed, 35 insertions(+), 55 deletions(-)
diff --git a/dlls/cabinet/fdi.c b/dlls/cabinet/fdi.c index 806a978..4c499dd 100644 --- a/dlls/cabinet/fdi.c +++ b/dlls/cabinet/fdi.c @@ -2277,6 +2277,39 @@ static void free_decompression_temps(HFDI hfdi, struct fdi_folder *fol, } }
+static void free_decompression_mem(HFDI hfdi, struct fdi_folder *fol, + fdi_decomp_state *decomp_state, fdi_decomp_state *sentinel_decomp_state, + struct fdi_file *file) +{ + while (decomp_state) { + fdi_decomp_state *prev_fds; + + PFDI_CLOSE(hfdi, CAB(cabhf)); + + /* free the storage remembered by mii */ + if (CAB(mii).nextname) PFDI_FREE(hfdi, CAB(mii).nextname); + if (CAB(mii).nextinfo) PFDI_FREE(hfdi, CAB(mii).nextinfo); + if (CAB(mii).prevname) PFDI_FREE(hfdi, CAB(mii).prevname); + if (CAB(mii).previnfo) PFDI_FREE(hfdi, CAB(mii).previnfo); + + while (CAB(firstfol)) { + fol = CAB(firstfol); + CAB(firstfol) = CAB(firstfol)->next; + PFDI_FREE(hfdi, fol); + } + while (CAB(firstfile)) { + file = CAB(firstfile); + if (file->filename) PFDI_FREE(hfdi, (void *)file->filename); + CAB(firstfile) = CAB(firstfile)->next; + PFDI_FREE(hfdi, file); + } + prev_fds = decomp_state; + decomp_state = CAB(next); + if (prev_fds != sentinel_decomp_state) + PFDI_FREE(hfdi, prev_fds); + } +} + /*********************************************************************** * FDICopy (CABINET.22) * @@ -2859,34 +2892,7 @@ BOOL __cdecl FDICopy( }
free_decompression_temps(hfdi, fol, decomp_state); - - while (decomp_state) { - fdi_decomp_state *prev_fds; - - PFDI_CLOSE(hfdi, CAB(cabhf)); - - /* free the storage remembered by mii */ - if (CAB(mii).nextname) PFDI_FREE(hfdi, CAB(mii).nextname); - if (CAB(mii).nextinfo) PFDI_FREE(hfdi, CAB(mii).nextinfo); - if (CAB(mii).prevname) PFDI_FREE(hfdi, CAB(mii).prevname); - if (CAB(mii).previnfo) PFDI_FREE(hfdi, CAB(mii).previnfo); - - while (CAB(firstfol)) { - fol = CAB(firstfol); - CAB(firstfol) = CAB(firstfol)->next; - PFDI_FREE(hfdi, fol); - } - while (CAB(firstfile)) { - file = CAB(firstfile); - if (file->filename) PFDI_FREE(hfdi, (void *)file->filename); - CAB(firstfile) = CAB(firstfile)->next; - PFDI_FREE(hfdi, file); - } - prev_fds = decomp_state; - decomp_state = CAB(next); - if (prev_fds != &_decomp_state) - PFDI_FREE(hfdi, prev_fds); - } + free_decompression_mem(hfdi, fol, decomp_state, &_decomp_state, file);
return TRUE;
@@ -2896,33 +2902,7 @@ BOOL __cdecl FDICopy(
if (filehf) PFDI_CLOSE(hfdi, filehf);
- while (decomp_state) { - fdi_decomp_state *prev_fds; - - PFDI_CLOSE(hfdi, CAB(cabhf)); - - /* free the storage remembered by mii */ - if (CAB(mii).nextname) PFDI_FREE(hfdi, CAB(mii).nextname); - if (CAB(mii).nextinfo) PFDI_FREE(hfdi, CAB(mii).nextinfo); - if (CAB(mii).prevname) PFDI_FREE(hfdi, CAB(mii).prevname); - if (CAB(mii).previnfo) PFDI_FREE(hfdi, CAB(mii).previnfo); - - while (CAB(firstfol)) { - fol = CAB(firstfol); - CAB(firstfol) = CAB(firstfol)->next; - PFDI_FREE(hfdi, fol); - } - while (CAB(firstfile)) { - file = CAB(firstfile); - if (file->filename) PFDI_FREE(hfdi, (void *)file->filename); - CAB(firstfile) = CAB(firstfile)->next; - PFDI_FREE(hfdi, file); - } - prev_fds = decomp_state; - decomp_state = CAB(next); - if (prev_fds != &_decomp_state) - PFDI_FREE(hfdi, prev_fds); - } + free_decompression_mem(hfdi, fol, decomp_state, &_decomp_state, file);
return FALSE; }