Skip to content

Commit

Permalink
Shorten the number of passes for performance reasons. Also fix memory…
Browse files Browse the repository at this point in the history
… leak
  • Loading branch information
ADBeveridge committed Aug 15, 2023
1 parent b10f1da commit 891d4c1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
16 changes: 2 additions & 14 deletions src/corrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/raider-file-row.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 891d4c1

Please sign in to comment.