AmendHub

Download:

jcs

/

subtext

/

amendments

/

335

binkp: Use grow_to_fit, handle failure


jcs made amendment 335 about 1 year ago
--- binkp.c Wed Mar 1 09:37:41 2023 +++ binkp.c Thu Mar 2 09:45:20 2023 @@ -585,7 +585,7 @@ binkp_ingest(void) HFileInfo *fpb = (HFileInfo *)&cipbr; DirInfo *dpb = (DirInfo *)&cipbr; CMovePBRec cmpbr = { 0 }; - Str255 file_name, abs_path, done_abs_path; + Str255 file_name_c, abs_path, done_abs_path; short dir_id, error; unsigned long started = Time; long n, j; @@ -604,11 +604,9 @@ binkp_ingest(void) } dir_id = dpb->ioDrDirID; - PtoCstr(binkp_dir); - - fpb->ioNamePtr = file_name; + fpb->ioNamePtr = file_name_c; for (;;) { - file_name[0] = 0; + file_name_c[0] = 0; fpb->ioDirID = dir_id; /* * Keep requesting the first item in the directory since we're @@ -619,13 +617,15 @@ binkp_ingest(void) error = PBGetCatInfo(&cipbr, false); if (error) break; + + PtoCstr(file_name_c); - PtoCstr(file_name); - + PtoCstr(binkp_dir); snprintf((char *)abs_path, sizeof(abs_path), "%s:%s", - binkp_dir, file_name); + binkp_dir, file_name_c); logger_printf("[binkp] processing zip file %s", (char *)abs_path); CtoPstr(abs_path); + CtoPstr(binkp_dir); binkp_fidopkt_skipped = 0; binkp_fidopkt_imported = 0; @@ -639,12 +639,12 @@ binkp_ingest(void) } logger_printf("[binkp] %s: imported %d, skipped %d", - (char *)file_name, binkp_fidopkt_imported, + (char *)file_name_c, binkp_fidopkt_imported, binkp_fidopkt_skipped); PtoCstr(binkp_done_dir); snprintf((char *)done_abs_path, sizeof(done_abs_path), - "%s:%s", binkp_done_dir, file_name); + "%s:%s", binkp_done_dir, file_name_c); CtoPstr(done_abs_path); CtoPstr(binkp_done_dir); @@ -678,9 +678,6 @@ try_rename: } } - CtoPstr(binkp_dir); - CtoPstr(binkp_done_dir); - for (n = 0; n < binkp_ntouched_boards; n++) { for (j = 0; j < db->nboards; j++) { if (db->boards[j].id == binkp_touched_boards[n]) { @@ -818,7 +815,7 @@ binkp_zip_processor(char *filename, size_t size, unsig ret = bile_marshall_object(board->bile, board_fidonet_post_object_fields, - nboard_fidonet_post_object_fields, &post, &pdata, &psize, "post"); + nboard_fidonet_post_object_fields, &post, &pdata, &psize); if (ret != 0 || psize == 0) { logger_printf("[fidopkt] failed to marshall new post %s %s", fidopkt->area, fidopkt->msgid_orig); @@ -849,10 +846,9 @@ binkp_zip_processor(char *filename, size_t size, unsig } } if (!found) { - EXPAND_TO_FIT(binkp_touched_boards, - binkp_touched_boards_size, (binkp_ntouched_boards * sizeof(long)), - sizeof(long), sizeof(long)); - binkp_touched_boards[binkp_ntouched_boards++] = board->id; + if (grow_to_fit(&binkp_touched_boards, &binkp_touched_boards_size, + (binkp_ntouched_boards * sizeof(long)), sizeof(long), sizeof(long))) + binkp_touched_boards[binkp_ntouched_boards++] = board->id; } #ifdef BINKP_DEBUG