Index: aim.c
===================================================================
--- aim.c	(revision 9854278fd0ac47586e8157e1efa798dd2583d81e)
+++ aim.c	(revision 34509d514dfa9ee441febffc6d61e108962d1507)
@@ -948,5 +948,5 @@
   
   if (modname) {
-    if (!(filename = malloc(strlen(priv->aimbinarypath)+1+strlen(modname)+4+1))) {
+    if (!(filename = owl_malloc(strlen(priv->aimbinarypath)+1+strlen(modname)+4+1))) {
       /* perror("memrequest: malloc"); */
       return -1;
@@ -954,5 +954,5 @@
     sprintf(filename, "%s/%s.ocm", priv->aimbinarypath, modname);
   } else {
-    if (!(filename = malloc(strlen(priv->aimbinarypath)+1+strlen(defaultmod)+1))) {
+    if (!(filename = owl_malloc(strlen(priv->aimbinarypath)+1+strlen(defaultmod)+1))) {
       /* perror("memrequest: malloc"); */
       return -1;
@@ -964,5 +964,5 @@
     if (!modname) {
       /* perror("memrequest: stat"); */
-      free(filename);
+      owl_free(filename);
       return -1;
     }
@@ -986,5 +986,5 @@
     int i;
     
-    free(filename); /* not needed */
+    owl_free(filename); /* not needed */
     owl_function_error("getaimdata memrequest: recieved invalid request for 0x%08lx bytes at 0x%08lx (file %s)\n", len, offset, modname);
     i = 8;
@@ -993,5 +993,5 @@
     }
     
-    if (!(buf = malloc(i))) {
+    if (!(buf = owl_malloc(i))) {
       return -1;
     }
@@ -1017,6 +1017,6 @@
     *buflenret = i;
   } else {
-    if (!(buf = malloc(len))) {
-      free(filename);
+    if (!(buf = owl_malloc(len))) {
+      owl_free(filename);
       return -1;
     }
@@ -1024,15 +1024,15 @@
     if (!(f = fopen(filename, "r"))) {
       /* perror("memrequest: fopen"); */
-      free(filename);
-      free(buf);
+      owl_free(filename);
+      owl_free(buf);
       return -1;
     }
     
-    free(filename);
+    owl_free(filename);
     
     if (fseek(f, offset, SEEK_SET) == -1) {
       /* perror("memrequest: fseek"); */
       fclose(f);
-      free(buf);
+      owl_free(buf);
       return -1;
     }
@@ -1041,5 +1041,5 @@
       /* perror("memrequest: fread"); */
       fclose(f);
-      free(buf);
+      owl_free(buf);
       return -1;
     }
@@ -1076,5 +1076,5 @@
   if (priv->aimbinarypath && (getaimdata(sess, &buf, &buflen, offset, len, modname) == 0)) {
     aim_sendmemblock(sess, fr->conn, offset, buflen, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST);
-    free(buf);
+    owl_free(buf);
   } else {
     owl_function_debugmsg("faimtest_memrequest: unable to use AIM binary (\"%s/%s\"), sending defaults...\n", priv->aimbinarypath, modname);
@@ -1342,10 +1342,10 @@
       int z;
       
-      newbuf = malloc(i+1);
+      newbuf = owl_malloc(i+1);
       for (z = 0; z < i; z++)
 	newbuf[z] = (z % 10)+0x30;
       newbuf[i] = '\0';
       /* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_ACK | AIM_IMFLAGS_AWAY, newbuf); */
-      free(newbuf);
+      owl_free(newbuf);
     }
   } else if (strstr(tmpstr, "seticqstatus")) {
Index: cmd.c
===================================================================
--- cmd.c	(revision 6922eddf979a8bdbf46a21cad138b787a7719f46)
+++ cmd.c	(revision 34509d514dfa9ee441febffc6d61e108962d1507)
@@ -74,5 +74,5 @@
   owl_cmd *cmd;
 
-  tmpbuff=strdup(cmdbuff);
+  tmpbuff=owl_strdup(cmdbuff);
   argv=owl_parseline(tmpbuff, &argc);
   if (argc < 0) {
Index: configure.in
===================================================================
--- configure.in	(revision 1d7e09467cf61d9a4f4eb63da4ce1ae39940b259)
+++ configure.in	(revision 34509d514dfa9ee441febffc6d61e108962d1507)
@@ -12,4 +12,6 @@
 fi
 
+dnl m4_include(/usr/share/aclocal/pkg.m4)
+m4_include(pkg.m4)
 
 dnl Check for Athena
@@ -105,4 +107,13 @@
 LDFLAGS=${LDFLAGS}\ ${FOO}
 
+dnl Add CFLAGS and LDFLAGS for glib-2.0
+PKG_CHECK_MODULES(GLIB,glib-2.0)
+
+echo Adding glib-2.0 CFLAGS ${GLIB_CFLAGS}
+CFLAGS=${CFLAGS}\ ${GLIB_CFLAGS}
+echo Adding glib-2.0 LDFLAGS ${GLIB_LIBS}
+LDFLAGS=${LDFLAGS}\ ${GLIB_LIBS}
+
+
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_CHECK_FILE(/usr/share/terminfo, AC_DEFINE(TERMINFO, "/usr/share/terminfo", [Have terminfo]),
Index: functions.c
===================================================================
--- functions.c	(revision 48609ce969ee2eb01da64338f4e477e0049acc22)
+++ functions.c	(revision 34509d514dfa9ee441febffc6d61e108962d1507)
@@ -3025,6 +3025,6 @@
 
   /* first, create the filter */
-  f=malloc(sizeof(owl_filter));
-  buff=malloc(strlen(class)+strlen(inst)+strlen(recip)+100);
+  f=owl_malloc(sizeof(owl_filter));
+  buff=owl_malloc(strlen(class)+strlen(inst)+strlen(recip)+100);
   strcpy(buff, "class");
   if (!strcmp(class, "*")) {
@@ -3314,5 +3314,5 @@
           if (ret==0) {
             for (x=0; x<numlocs; x++) {
-              line=malloc(strlen(location[x].host)+strlen(location[x].time)+strlen(location[x].tty)+100);
+              line=owl_malloc(strlen(location[x].host)+strlen(location[x].time)+strlen(location[x].tty)+100);
               tmp=short_zuser(user);
               sprintf(line, "  %-10.10s %-24.24s %-12.12s  %20.20s\n",
@@ -3420,5 +3420,5 @@
 	  _exit(127);
 	}
-	parsed=realloc(parsed, sizeof(*parsed) * (myargc+1));
+	parsed=owl_realloc(parsed, sizeof(*parsed) * (myargc+1));
 	parsed[myargc] = NULL;
 	
Index: global.c
===================================================================
--- global.c	(revision f1fc47f7249eeb9d23251efec92666308ba5898a)
+++ global.c	(revision 34509d514dfa9ee441febffc6d61e108962d1507)
@@ -518,5 +518,5 @@
     len+=strlen(argv[i])+5;
   }
-  g->startupargs=malloc(len+5);
+  g->startupargs=owl_malloc(len+5);
 
   strcpy(g->startupargs, "");
Index: message.c
===================================================================
--- message.c	(revision 9c590d4400a3cc43b25cb33b4d9e06086f77ec90)
+++ message.c	(revision 34509d514dfa9ee441febffc6d61e108962d1507)
@@ -487,5 +487,5 @@
 {
   if(m->zwriteline) owl_free(m->zwriteline);
-  m->zwriteline=strdup(line);
+  m->zwriteline=owl_strdup(line);
 }
 
@@ -882,5 +882,5 @@
   }
 
-  m->zwriteline=strdup("");
+  m->zwriteline=owl_strdup("");
 
   /* save the hostname */
@@ -964,5 +964,5 @@
   }
 
-  m->zwriteline=strdup("");
+  m->zwriteline=owl_strdup("");
 
   owl_message_set_body(m, "<uninitialized>");
Index: owl.c
===================================================================
--- owl.c	(revision 13a3c1db689b9429147996774625ca630c1b93cd)
+++ owl.c	(revision 34509d514dfa9ee441febffc6d61e108962d1507)
@@ -48,4 +48,5 @@
 #include <termios.h>
 #include <sys/stat.h>
+#include <locale.h>
 #include "owl.h"
 
@@ -90,4 +91,7 @@
   debug=0;
   initialsubs=1;
+
+  setlocale(LC_ALL, "");
+  
   if (argc>0) {
     argv++;
Index: owl.h
===================================================================
--- owl.h	(revision 80e54a7631f091be8c9762adb9746bad38104738)
+++ owl.h	(revision 34509d514dfa9ee441febffc6d61e108962d1507)
@@ -53,4 +53,5 @@
 #include <libfaim/aim.h>
 #include "config.h"
+#include "glib.h"
 #ifdef HAVE_LIBZEPHYR
 #include <zephyr/zephyr.h>
Index: text.c
===================================================================
--- text.c	(revision 72db971652f37640c13d75944eeb6eaf0fff645a)
+++ text.c	(revision 34509d514dfa9ee441febffc6d61e108962d1507)
@@ -327,5 +327,5 @@
   tolen  = strlen(to);
   fromlen  = strlen(from);
-  out = malloc(outlen);
+  out = owl_malloc(outlen);
 
   while (in[inpos]) {
Index: util.c
===================================================================
--- util.c	(revision c2c5c7772ea161470617ef920e22ef7570df5238)
+++ util.c	(revision 34509d514dfa9ee441febffc6d61e108962d1507)
@@ -446,20 +446,20 @@
 void *owl_malloc(size_t size)
 {
-  return(malloc(size));
+  return(g_malloc(size));
 }
 
 void owl_free(void *ptr)
 {
-  free(ptr);
+  g_free(ptr);
 }
 
 char *owl_strdup(const char *s1)
 {
-  return(strdup(s1));
+  return(g_strdup(s1));
 }
 
 void *owl_realloc(void *ptr, size_t size)
 {
-  return(realloc(ptr, size));
+  return(g_realloc(ptr, size));
 }
 
Index: zcrypt.c
===================================================================
--- zcrypt.c	(revision 9ceee9d93177e80e7794f45d5ba9e611169e4d55)
+++ zcrypt.c	(revision 34509d514dfa9ee441febffc6d61e108962d1507)
@@ -385,5 +385,5 @@
 
 /* Build a space-separated string from argv from elements between start  *
- * and end - 1.  malloc()'s the returned string. */
+ * and end - 1.  owl_malloc()'s the returned string. */
 char *BuildArgString(char **argv, int start, int end) {
   int len = 1;
@@ -397,5 +397,5 @@
 
   /* Allocate memory */
-  result = (char *)malloc(len);
+  result = (char *)owl_malloc(len);
   if (result) {
     /* Build the string */
@@ -482,5 +482,5 @@
       /* Prepare result to be returned */
       char *temp = keyfile;
-      keyfile = (char *)malloc(strlen(temp) + 1);
+      keyfile = (char *)owl_malloc(strlen(temp) + 1);
       if (keyfile) {
 	strcpy(keyfile, temp);
@@ -611,5 +611,5 @@
       }
       use_buffer = TRUE;
-      if ((inptr = inbuff = (char *)malloc(MAX_RESULT)) == NULL) {
+      if ((inptr = inbuff = (char *)owl_malloc(MAX_RESULT)) == NULL) {
 	printf("Memory allocation error\n");
 	return FALSE;
@@ -639,5 +639,5 @@
       printf("Could not run zwrite\n");
       if (freein && inbuff) {
-	free(inbuff);
+	owl_free(inbuff);
       }
       return(FALSE);
@@ -685,5 +685,5 @@
 
   /* Free the input buffer, if necessary */
-  if (freein && inbuff) free(inbuff);
+  if (freein && inbuff) owl_free(inbuff);
 
   return(!error);
Index: zwrite.c
===================================================================
--- zwrite.c	(revision db2dd3d7ef308a3ef1bbf34331fb91a26178e0e4)
+++ zwrite.c	(revision 34509d514dfa9ee441febffc6d61e108962d1507)
@@ -95,5 +95,5 @@
       z->message=owl_strdup("");
       while (myargc) {
-	z->message=realloc(z->message, strlen(z->message)+strlen(myargv[0])+5);
+	z->message=owl_realloc(z->message, strlen(z->message)+strlen(myargv[0])+5);
 	strcat(z->message, myargv[0]);
 	strcat(z->message, " ");
@@ -113,5 +113,5 @@
     } else {
       /* anything unattached is a recipient */
-      owl_list_append_element(&(z->recips), strdup(myargv[0]));
+      owl_list_append_element(&(z->recips), owl_strdup(myargv[0]));
       myargv++;
       myargc--;
@@ -177,5 +177,5 @@
       z->zsig=owl_strdup(zsigzvar);
     } else if (((pw=getpwuid(getuid()))!=NULL) && (pw->pw_gecos)) {
-      z->zsig=strdup(pw->pw_gecos);
+      z->zsig=owl_strdup(pw->pw_gecos);
       ptr=strchr(z->zsig, ',');
       if (ptr) {
