+ /* We can use a static buffer here because there will never be more than
+ * one of this operation happening at any given time, and it's really best
+ * to just keep it allocated once instead of torturing malloc/free.
+ * Call this function with msgnum "-1" to free the buffer when finished.
+ */
+ static int encoded_alloc = 0;
+ static char *encoded_msg = NULL;
+
+ if (msgnum < 0) {
+ if ((encoded_alloc == 0) && (encoded_msg != NULL)) {
+ free(encoded_msg);
+ encoded_alloc = 0;
+ encoded_msg = NULL;
+ }
+ return;
+ }
+
+ /* Ok, here we go ... */
+