diff --git a/builds/amiga/src/base/ftsystem.c b/builds/amiga/src/base/ftsystem.c
index 53abdb0..031bd29 100644
--- a/builds/amiga/src/base/ftsystem.c
+++ b/builds/amiga/src/base/ftsystem.c
@@ -139,7 +139,7 @@ Free_VecPooled( APTR  poolHeader,
   /*                                                                       */
   FT_CALLBACK_DEF( void* )
   ft_alloc( FT_Memory  memory,
-            long       size )
+            size_t     size )
   {
 #ifdef __amigaos4__
     return AllocVecPooled( memory->user, size );
@@ -171,8 +171,8 @@ Free_VecPooled( APTR  poolHeader,
   /*                                                                       */
   FT_CALLBACK_DEF( void* )
   ft_realloc( FT_Memory  memory,
-              long       cur_size,
-              long       new_size,
+              size_t     cur_size,
+              size_t     new_size,
               void*      block )
   {
     void* new_block;
diff --git a/builds/unix/ftsystem.c b/builds/unix/ftsystem.c
index 449c0ed..8e70988 100644
--- a/builds/unix/ftsystem.c
+++ b/builds/unix/ftsystem.c
@@ -95,7 +95,7 @@
   /*                                                                       */
   FT_CALLBACK_DEF( void* )
   ft_alloc( FT_Memory  memory,
-            long       size )
+            size_t     size )
   {
     FT_UNUSED( memory );
 
@@ -125,8 +125,8 @@
   /*                                                                       */
   FT_CALLBACK_DEF( void* )
   ft_realloc( FT_Memory  memory,
-              long       cur_size,
-              long       new_size,
+              size_t     cur_size,
+              size_t     new_size,
               void*      block )
   {
     FT_UNUSED( memory );
diff --git a/builds/vms/ftsystem.c b/builds/vms/ftsystem.c
index 71aab35..51a7a3f 100644
--- a/builds/vms/ftsystem.c
+++ b/builds/vms/ftsystem.c
@@ -94,7 +94,7 @@
   /*                                                                       */
   FT_CALLBACK_DEF( void* )
   ft_alloc( FT_Memory  memory,
-            long       size )
+            size_t     size )
   {
     FT_UNUSED( memory );
 
@@ -124,8 +124,8 @@
   /*                                                                       */
   FT_CALLBACK_DEF( void* )
   ft_realloc( FT_Memory  memory,
-              long       cur_size,
-              long       new_size,
+              size_t     cur_size,
+              size_t     new_size,
               void*      block )
   {
     FT_UNUSED( memory );
diff --git a/include/freetype/ftsystem.h b/include/freetype/ftsystem.h
index d6947f5..1dd853b 100644
--- a/include/freetype/ftsystem.h
+++ b/include/freetype/ftsystem.h
@@ -21,6 +21,7 @@
 
 
 #include <ft2build.h>
+#include FT_CONFIG_STANDARD_LIBRARY_H
 
 
 FT_BEGIN_HEADER
@@ -86,7 +87,7 @@ FT_BEGIN_HEADER
    */
   typedef void*
   (*FT_Alloc_Func)( FT_Memory  memory,
-                    long       size );
+                    size_t     size );
 
 
   /**************************************************************************
@@ -140,8 +141,8 @@ FT_BEGIN_HEADER
    */
   typedef void*
   (*FT_Realloc_Func)( FT_Memory  memory,
-                      long       cur_size,
-                      long       new_size,
+                      size_t     cur_size,
+                      size_t     new_size,
                       void*      block );
 
 
diff --git a/src/base/ftdbgmem.c b/src/base/ftdbgmem.c
index 6e0a074..5410ead 100644
--- a/src/base/ftdbgmem.c
+++ b/src/base/ftdbgmem.c
@@ -676,14 +676,14 @@
 
   static FT_Pointer
   ft_mem_debug_alloc( FT_Memory  memory,
-                      FT_Long    size )
+                      FT_Offset  size )
   {
     FT_MemTable  table = (FT_MemTable)memory->user;
     FT_Byte*     block;
 
 
-    if ( size <= 0 )
-      ft_mem_debug_panic( "negative block size allocation (%ld)", size );
+    if ( size == 0 )
+      ft_mem_debug_panic( "zero block size allocation (%ld)", size );
 
     /* return NULL if the maximum number of allocations was reached */
     if ( table->bound_count                           &&
@@ -736,8 +736,8 @@
 
   static FT_Pointer
   ft_mem_debug_realloc( FT_Memory   memory,
-                        FT_Long     cur_size,
-                        FT_Long     new_size,
+                        FT_Offset   cur_size,
+                        FT_Offset   new_size,
                         FT_Pointer  block )
   {
     FT_MemTable  table = (FT_MemTable)memory->user;
@@ -762,7 +762,7 @@
 
     /* while the following is allowed in ANSI C also, we abort since */
     /* such case should be handled by FreeType.                      */
-    if ( new_size <= 0 )
+    if ( new_size == 0 )
       ft_mem_debug_panic(
         "trying to reallocate %p to size 0 (current is %ld) in (%s:%ld)",
         block, cur_size, file_name, line_no );
@@ -804,8 +804,8 @@
 
     ft_mem_table_set( table, (FT_Byte*)new_block, new_size, delta );
 
-    ft_memcpy( new_block, block, cur_size < new_size ? (size_t)cur_size
-                                                     : (size_t)new_size );
+    ft_memcpy( new_block, block, cur_size < new_size ? cur_size
+                                                     : new_size );
 
     ft_mem_table_remove( table, (FT_Byte*)block, delta );
 
diff --git a/src/base/ftsystem.c b/src/base/ftsystem.c
index 8fffe48..ded49a4 100644
--- a/src/base/ftsystem.c
+++ b/src/base/ftsystem.c
@@ -69,11 +69,11 @@
    */
   FT_CALLBACK_DEF( void* )
   ft_alloc( FT_Memory  memory,
-            long       size )
+            size_t     size )
   {
     FT_UNUSED( memory );
 
-    return ft_smalloc( (size_t)size );
+    return ft_smalloc( size );
   }
 
 
@@ -103,14 +103,14 @@
    */
   FT_CALLBACK_DEF( void* )
   ft_realloc( FT_Memory  memory,
-              long       cur_size,
-              long       new_size,
+              size_t     cur_size,
+              size_t     new_size,
               void*      block )
   {
     FT_UNUSED( memory );
     FT_UNUSED( cur_size );
 
-    return ft_srealloc( block, (size_t)new_size );
+    return ft_srealloc( block, new_size );
   }
 
 
diff --git a/src/raster/ftmisc.h b/src/raster/ftmisc.h
index 97db371..fb63a02 100644
--- a/src/raster/ftmisc.h
+++ b/src/raster/ftmisc.h
@@ -59,14 +59,14 @@
   typedef struct FT_MemoryRec_*  FT_Memory;
 
   typedef void* (*FT_Alloc_Func)( FT_Memory  memory,
-                                  long       size );
+                                  size_t     size );
 
   typedef void (*FT_Free_Func)( FT_Memory  memory,
                                 void*      block );
 
   typedef void* (*FT_Realloc_Func)( FT_Memory  memory,
-                                    long       cur_size,
-                                    long       new_size,
+                                    size_t     cur_size,
+                                    size_t     new_size,
                                     void*      block );
 
   typedef struct FT_MemoryRec_
