Migrated the Memory layer to the Platform layer

Deprecated POLARSSL_MEMORY_C and placed placeholder for memory.h to make
sure current code will not break on new version.
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index d948ca0..2d74559 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -32,7 +32,6 @@
      md2.c
      md4.c
      md5.c
-     memory.c
      memory_buffer_alloc.c
      net.c
      oid.c
diff --git a/library/Makefile b/library/Makefile
index 9316024..a4a3ce7 100644
--- a/library/Makefile
+++ b/library/Makefile
@@ -46,7 +46,7 @@
 		error.o		gcm.o		havege.o		\
 		hmac_drbg.o								\
 		md.o		md_wrap.o	md2.o			\
-		md4.o		md5.o		memory.o		\
+		md4.o		md5.o						\
 		memory_buffer_alloc.o	net.o			\
 		oid.o									\
 		padlock.o	pbkdf2.o	pem.o			\
diff --git a/library/memory.c b/library/memory.c
deleted file mode 100644
index 93ca379..0000000
--- a/library/memory.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- *  Memory allocation layer
- *
- *  Copyright (C) 2006-2013, Brainspark B.V.
- *
- *  This file is part of PolarSSL (http://www.polarssl.org)
- *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
- *
- *  All rights reserved.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "polarssl/config.h"
-
-#if defined(POLARSSL_MEMORY_C)
-
-#include "polarssl/memory.h"
-
-#if !defined(POLARSSL_MEMORY_STDMALLOC)
-static void *memory_malloc_uninit( size_t len )
-{
-    ((void) len);
-    return( NULL );
-}
-
-#define POLARSSL_MEMORY_STDMALLOC   memory_malloc_uninit
-#endif /* !POLARSSL_MEMORY_STDMALLOC */
-
-#if !defined(POLARSSL_MEMORY_STDFREE)
-static void memory_free_uninit( void *ptr )
-{
-    ((void) ptr);
-}
-
-#define POLARSSL_MEMORY_STDFREE     memory_free_uninit
-#endif /* !POLARSSL_MEMORY_STDFREE */
-
-void * (*polarssl_malloc)( size_t ) = POLARSSL_MEMORY_STDMALLOC;
-void (*polarssl_free)( void * )     = POLARSSL_MEMORY_STDFREE;
-
-int memory_set_own( void * (*malloc_func)( size_t ),
-                    void (*free_func)( void * ) )
-{
-    polarssl_malloc = malloc_func;
-    polarssl_free = free_func;
-
-    return( 0 );
-}
-
-#endif /* POLARSSL_MEMORY_C */
diff --git a/library/memory_buffer_alloc.c b/library/memory_buffer_alloc.c
index fef4331..2196891 100644
--- a/library/memory_buffer_alloc.c
+++ b/library/memory_buffer_alloc.c
@@ -25,9 +25,9 @@
 
 #include "polarssl/config.h"
 
-#if defined(POLARSSL_MEMORY_C) && defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
+#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
 
-#include "polarssl/memory.h"
+#include "polarssl/memory_buffer_alloc.h"
 
 #include <string.h>
 
@@ -544,11 +544,10 @@
 
 #if defined(POLARSSL_THREADING_C)
     polarssl_mutex_init( &heap.mutex );
-    polarssl_malloc = buffer_alloc_malloc_mutexed;
-    polarssl_free = buffer_alloc_free_mutexed;
+    platform_set_malloc_free( buffer_alloc_malloc_mutexed,
+                              buffer_alloc_free_mutexed );
 #else
-    polarssl_malloc = buffer_alloc_malloc;
-    polarssl_free = buffer_alloc_free;
+    platform_set_malloc_free( buffer_alloc_malloc, buffer_alloc_free );
 #endif
 
     heap.buf = buf;
@@ -570,4 +569,4 @@
     memset( &heap, 0, sizeof(buffer_alloc_ctx) );
 }
 
-#endif /* POLARSSL_MEMORY_C && POLARSSL_MEMORY_BUFFER_ALLOC_C */
+#endif /* POLARSSL_MEMORY_BUFFER_ALLOC_C */
diff --git a/library/platform.c b/library/platform.c
index 32f949f..823b17d 100644
--- a/library/platform.c
+++ b/library/platform.c
@@ -29,6 +29,38 @@
 
 #include "polarssl/platform.h"
 
+#if defined(POLARSSL_PLATFORM_MEMORY)
+#if !defined(POLARSSL_PLATFORM_STD_MALLOC)
+static void *platform_malloc_uninit( size_t len )
+{
+    ((void) len);
+    return( NULL );
+}
+
+#define POLARSSL_PLATFORM_STD_MALLOC   memory_malloc_uninit
+#endif /* !POLARSSL_PLATFORM_STD_MALLOC */
+
+#if !defined(POLARSSL_PLATFORM_STD_FREE)
+static void platform_free_uninit( void *ptr )
+{
+    ((void) ptr);
+}
+
+#define POLARSSL_PLATFORM_STD_FREE     memory_free_uninit
+#endif /* !POLARSSL_PLATFORM_STD_FREE */
+
+void * (*polarssl_malloc)( size_t ) = POLARSSL_PLATFORM_STD_MALLOC;
+void (*polarssl_free)( void * )     = POLARSSL_PLATFORM_STD_FREE;
+
+int platform_set_malloc_free( void * (*malloc_func)( size_t ),
+                              void (*free_func)( void * ) )
+{
+    polarssl_malloc = malloc_func;
+    polarssl_free = free_func;
+    return( 0 );
+}
+#endif /* POLARSSL_PLATFORM_MEMORY */
+
 #if defined(POLARSSL_PLATFORM_PRINTF_ALT)
 #if !defined(POLARSSL_PLATFORM_STD_PRINTF)
 /*