From 891d4c1e54a6aa242d58b0d306e44e0ffef9ddb8 Mon Sep 17 00:00:00 2001 From: Alan Beveridge Date: Tue, 15 Aug 2023 14:35:30 -0700 Subject: [PATCH] Shorten the number of passes for performance reasons. Also fix memory leak --- src/corrupt.c | 16 ++-------------- src/raider-file-row.c | 3 +-- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/corrupt.c b/src/corrupt.c index 0475382..b4345bb 100644 --- a/src/corrupt.c +++ b/src/corrupt.c @@ -102,13 +102,12 @@ static uint8_t corrupt_step(RaiderCorrupt* corrupt, const off_t filesize, const fwrite(pattern, sizeof(char), length, fp); if (g_task_return_error_if_cancelled (corrupt->task)) {fclose(fp);return 1;} - double current = ((double)loop_num/32.0) + (double)i/times*1.0/32.0; + double current = ((double)loop_num/10.0) + (double)i/times*1.0/10.0; // Only update the progress when the jump is large enough. if (current - corrupt->progress >= .01) { corrupt->progress = current; - printf("%d, %f\n", loop_num, current); raider_file_row_set_progress_num(corrupt->row, corrupt->progress); g_main_context_invoke (NULL, raider_file_row_set_progress, corrupt->row); @@ -124,19 +123,8 @@ uint8_t corrupt_file(RaiderCorrupt* corrupt) const char* steps[] = {"\x77\x77\x77", "\x76\x76\x76", "\x33\x33\x33", "\x35\x35\x35", "\x55\x55\x55", "\xAA\xAA\xAA", - "\x92\x49\x24", "\x49\x24\x92", - "\x55\x55\x55", "\x20\x02\x03", - "\x11\x11\x11", "\x01\x01\x01", - "\x22\x22\x22", "\x33\x33\x33", "\x44\x44\x44", "\x55\x55\x55", - "\x66\x66\x66", "\x77\x77\x77", - "\x88\x88\x88", "\x99\x99\x99", - "\xAA\xAA\xAA", "\xBB\xBB\xBB", - "\xCC\xCC\xCC", "\xDD\xDD\xDD", - "\xEE\xEE\xEE", "\xFF\xFF\xFF", - "\x92\x49\x24", "\x49\x24\x92", - "\x24\x92\x49", "\x6D\xB6\xDB", - "\xB6\xDB\x6D", "\xDB\x6D\xB6"}; + "\x66\x66\x66", "\x77\x77\x77"}; int steps_num = sizeof(steps) / sizeof(steps[0]); uint8_t ret = 0; diff --git a/src/raider-file-row.c b/src/raider-file-row.c index d021ed7..44e0b85 100644 --- a/src/raider-file-row.c +++ b/src/raider-file-row.c @@ -128,11 +128,10 @@ static void raider_file_row_close (GtkWidget* window, gpointer data) /** Shredding section */ void shredding_finished(GObject *source_object, GAsyncResult *res, gpointer user_data) { - printf("Done\n"); - RaiderFileRow* row = g_task_get_task_data(G_TASK(res)); g_mutex_unlock (&row->mutex); + g_object_unref(row->cancel); /* Make sure that the user can use the window after the row is destroyed. */ gtk_widget_set_visible(GTK_WIDGET(row->popover), FALSE);