X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=printing.c;h=17bf6ffa08f112a9a9568a6094c183496b41d185;hb=87fd7a4858fdbafdf5b1b42b779ce282d01c0a40;hp=d40e2ac000f72fe265d95d7cdf82161ac5f667d2;hpb=17b4eb4cafd0ac0aea155e450dabd435ba29c10d;p=PuTTY_svn.git diff --git a/printing.c b/printing.c index d40e2ac0..17bf6ffa 100644 --- a/printing.c +++ b/printing.c @@ -39,9 +39,13 @@ static char *printer_add_enum(int param, char *buffer, buffer = srealloc(buffer, offset+512); - if (EnumPrinters(param, NULL, ENUM_LEVEL, buffer+offset, - 512, &needed, &nprinters) == 0) - return NULL; + /* + * Exploratory call to EnumPrinters to determine how much space + * we'll need for the output. Discard the return value since it + * will almost certainly be a failure due to lack of space. + */ + EnumPrinters(param, NULL, ENUM_LEVEL, buffer+offset, 512, + &needed, &nprinters); if (needed < 512) needed = 512; @@ -65,14 +69,8 @@ printer_enum *printer_start_enum(int *nprinters_ptr) *nprinters_ptr = 0; /* default return value */ buffer = smalloc(512); - retval = printer_add_enum(PRINTER_ENUM_LOCAL, buffer, 0, nprinters_ptr); - if (!retval) - goto error; - else - buffer = retval; - retval = printer_add_enum(PRINTER_ENUM_CONNECTIONS, buffer, - sizeof(ENUM_TYPE) * *nprinters_ptr, - nprinters_ptr); + retval = printer_add_enum(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, + buffer, 0, nprinters_ptr); if (!retval) goto error; else