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;
*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