summaryrefslogtreecommitdiff
path: root/innobase/ut/ut0mem.c
diff options
context:
space:
mode:
Diffstat (limited to 'innobase/ut/ut0mem.c')
-rw-r--r--innobase/ut/ut0mem.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/innobase/ut/ut0mem.c b/innobase/ut/ut0mem.c
new file mode 100644
index 00000000000..492f57670a9
--- /dev/null
+++ b/innobase/ut/ut0mem.c
@@ -0,0 +1,69 @@
+/************************************************************************
+Memory primitives
+
+(c) 1994, 1995 Innobase Oy
+
+Created 5/11/1994 Heikki Tuuri
+*************************************************************************/
+
+#include "ut0mem.h"
+
+#ifdef UNIV_NONINL
+#include "ut0mem.ic"
+#endif
+
+#include "mem0mem.h"
+
+void*
+ut_malloc(ulint n)
+{
+ void* ret;
+ /*
+ ret = VirtualAlloc(NULL, n, MEM_COMMIT, PAGE_READWRITE);
+ */
+
+ ret = malloc(n);
+
+ if (ret == NULL) {
+ fprintf(stderr,
+ "Innobase: Fatal error: cannot allocate memory!\n");
+ fprintf(stderr,
+ "Innobase: Cannot continue operation!\n");
+ fprintf(stderr,
+ "Innobase: Check if you can increase the swap file of your\n");
+ fprintf(stderr,
+ "Innobase: operating system.\n");
+
+ exit(1);
+ }
+
+ return(ret);
+}
+
+/**************************************************************************
+Catenates two strings into newly allocated memory. The memory must be freed
+using mem_free. */
+
+char*
+ut_str_catenate(
+/*============*/
+ /* out, own: catenated null-terminated string */
+ char* str1, /* in: null-terminated string */
+ char* str2) /* in: null-terminated string */
+{
+ ulint len1;
+ ulint len2;
+ char* str;
+
+ len1 = ut_strlen(str1);
+ len2 = ut_strlen(str2);
+
+ str = mem_alloc(len1 + len2 + 1);
+
+ ut_memcpy(str, str1, len1);
+ ut_memcpy(str + len1, str2, len2);
+
+ str[len1 + len2] = '\0';
+
+ return(str);
+}