--- a/imsp/imsp_server.c
+++ b/imsp/imsp_server.c
@@ -46,6 +46,7 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
+#include <stdlib.h>
 #include <signal.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -69,9 +70,6 @@
 #include "alock.h"
 #include "sasl_support.h"
 
-/* import from OS */
-extern char *malloc(), *realloc();
-
 /* structure used for command dispatch list */
 typedef struct command_t {
     char *word;
--- a/imsp/abook.c
+++ b/imsp/abook.c
@@ -45,6 +45,7 @@
 #include <config.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 #include "xmalloc.h"
 #include "util.h"
 #include "syncdb.h"
@@ -56,9 +57,6 @@
 #include "acl.h"
 #include "option.h" /* for option_doquota() */
 
-/* import from OS: */
-extern char *malloc();
-
 /* database names */
 static char abooks[] = "abooks";
 static char abooksdb[] = "user/%s/abooks";
--- a/imsp/dispatch.c
+++ b/imsp/dispatch.c
@@ -47,6 +47,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <string.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/file.h>
--- a/imsp/im_util.c
+++ b/imsp/im_util.c
@@ -44,6 +44,7 @@
 
 #include <config.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <ctype.h>
 #include <string.h>
 #include <limits.h>
@@ -59,8 +60,6 @@
 #include <varargs.h>
 #endif
 
-/* import from OS: */
-extern char *malloc(), *realloc();
 #define MAX_DIGITS  32  /* max number of digits in long integer */
 
 /* flag that a literal is ready to be sent */
--- a/imsp/main.c
+++ b/imsp/main.c
@@ -44,6 +44,8 @@
 
 #include <config.h>
 #include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
 #include <signal.h>
 #include <errno.h>
 #include <sys/types.h>
--- a/imsp/option.c
+++ b/imsp/option.c
@@ -48,6 +48,8 @@
 #include <config.h>
 #include <stdio.h>
 #include <ctype.h>
+#include <string.h>
+#include <stdlib.h>
 #include "util.h"
 #include "syncdb.h"
 #include "option.h"
@@ -57,9 +59,6 @@
 /* from adate.c: */
 extern char *n_arpadate();
 
-/* from OS: */
-extern char *malloc(), *realloc();
-
 /* various strings */
 static char options[] = "options";
 static char optiondb[] = "user/%s/options";
--- a/lib/auth_unix.c
+++ b/lib/auth_unix.c
@@ -49,6 +49,7 @@
 #include <grp.h>
 #include <ctype.h>
 #include <string.h>
+#include <stdlib.h>
 
 #include "auth.h"
 #include "xmalloc.h"
--- a/lib/glob.c
+++ b/lib/glob.c
@@ -48,6 +48,7 @@
 #include <config.h>
 #include <ctype.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include "util.h"
 #include "glob.h"
--- a/imsp/adate.c
+++ b/imsp/adate.c
@@ -27,6 +27,7 @@
 
 #include <time.h>
 #include <string.h>
+#include <stdio.h>
 #include <sys/types.h>
 #include <sys/time.h>
 
--- a/imsp/syncdb.c
+++ b/imsp/syncdb.c
@@ -56,6 +56,7 @@
 #include <config.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/file.h>
--- a/imsp/authize.c
+++ b/imsp/authize.c
@@ -45,6 +45,7 @@
 #include <config.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 #include "util.h"
 #include "acl.h"
 #include "syncdb.h"
@@ -52,10 +53,6 @@
 #include "auth.h"
 #include "authize.h"
 
-/* from OS: */
-extern char *malloc(), *realloc();
-extern char *crypt();
-
 /* name of anonymous user */
 static char anonymous[] = "anonymous";
 
--- a/imsp/imap_client.c
+++ b/imsp/imap_client.c
@@ -26,6 +26,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/file.h>
@@ -42,9 +43,6 @@
 
 extern int from64();
 
-/* from OS: */
-extern char *malloc();
-
 /* proxy strings
  */
 static char proxy_login[]  = "%a LOGIN %s %s\r\n";
--- a/imsp/sasl_support.c
+++ b/imsp/sasl_support.c
@@ -44,7 +44,7 @@
 
 #include <config.h>
 #include <stdlib.h>
-#include <strings.h>
+#include <string.h>
 #include <syslog.h>
 #include <sasl/sasl.h>
 #include <netinet/in.h>
--- a/lib/util.c
+++ b/lib/util.c
@@ -48,11 +48,9 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
+#include <stdlib.h>
 #include "util.h"
 
-/* from OS: */
-extern char *malloc(), *realloc();
-
 #define BEAUTYBUFSIZE 4096
 
 const unsigned char convert_to_lowercase[256] = {
--- a/imsp/alock.c
+++ b/imsp/alock.c
@@ -44,6 +44,7 @@
 
 #include <config.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include "util.h"
 #include "syncdb.h"
