+
+int
+fput_cp (FILE * f, uint32_t ch)
+{
+ char buf[4];
+ int i;
+ i = utf8_encode (buf, ch);
+
+ if (!i)
+ return 0;
+
+ return fwrite (buf, i, 1, f);
+}
+
+void
+crash_out (char *why)
+{
+ terminal_atexit ();
+ fprintf (stderr, "sympathy is aborting: %s\n", why ? why : "");
+ exit (1);
+}
+
+void *
+xmalloc (size_t s)
+{
+ void *ret = malloc (s);
+ if (!ret)
+ crash_out ("malloc failed");
+ return ret;
+}
+
+void *
+xrealloc (void *p, size_t s)
+{
+ p = realloc (p, s);
+ if (!p)
+ crash_out ("realloc failed");
+ return p;
+}
+
+char *
+xstrdup (const char *s)
+{
+ char *ret = strdup (s);
+ if (!ret)
+ crash_out ("strdup failed");
+ return ret;
+}