List:Commits« Previous MessageNext Message »
From:Rafal Somla Date:March 30 2011 2:22pm
Subject:bzr commit into mysql-5.5 branch (rafal.somla:3376)
View as plain text  
#At D:/source/bzr2/mysql-5.5 based on revid:rafal.somla@stripped

 3376 Rafal Somla	2011-03-30
      Heap allocation service - only for review purposes.

    added:
      include/mysql/service_heap_alloc.h
      libservices/heap_alloc_service.c
    modified:
      include/mysql/services.h
      include/service_versions.h
      libservices/CMakeLists.txt
      sql/sql_plugin_services.h
=== added file 'include/mysql/service_heap_alloc.h'
--- a/include/mysql/service_heap_alloc.h	1970-01-01 00:00:00 +0000
+++ b/include/mysql/service_heap_alloc.h	2011-03-30 14:22:50 +0000
@@ -0,0 +1,60 @@
+#ifndef MYSQL_SERVICE_HEAP_ALLOC_INCLUDED
+/* Copyright (C) 2009 Sun Microsystems, Inc.
+
+   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; version 2 of the License.
+
+   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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+/**
+  @file
+  This service provdes functions to allocate memory on server's heap.
+*/
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef int myf;
+
+extern struct heap_alloc_service_st {
+  void* (*malloc)(size_t size, myf MyFlags);
+  void  (*free)(void* ptr);
+  void* (*realloc)(void* oldpoint, size_t size, myf MyFlags);
+} *heap_alloc_service;
+
+#ifdef MYSQL_DYNAMIC_PLUGIN
+
+#define MY_ZEROFILL       32  /* malloc(): fill array with zero */
+#define MY_ALLOW_ZERO_PTR 64  /* realloc(): zero ptr -> malloc */
+#define MY_FREE_ON_ERROR 128  /* realloc(): Free old ptr on error */
+#define MY_HOLD_ON_ERROR 256  /* realloc(): Return old ptr on error */
+
+#define heap_malloc(size, flags) (heap_alloc_service->malloc((size), myf(flags)))
+#define heap_free(ptr)           (heap_alloc_service->free((ptr)))
+#define heap_realloc(old, size, flags) (heap_alloc_service->realloc((old), (size), myf(flags)))
+
+#else
+
+extern void* my_malloc(size_t Size,myf MyFlags);
+extern void* my_realloc(void *oldpoint, size_t Size, myf MyFlags);
+extern void  my_free(void *ptr);
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#define MYSQL_SERVICE_HEAP_ALLOC_INCLUDED
+#endif
+

=== modified file 'include/mysql/services.h'
--- a/include/mysql/services.h	2010-06-07 14:01:39 +0000
+++ b/include/mysql/services.h	2011-03-30 14:22:50 +0000
@@ -22,6 +22,7 @@ extern "C" {
 #include <mysql/service_thd_alloc.h>
 #include <mysql/service_thd_wait.h>
 #include <mysql/service_thread_scheduler.h>
+#include <mysql/service_heap_alloc.h>
 
 #ifdef __cplusplus
 }

=== modified file 'include/service_versions.h'
--- a/include/service_versions.h	2010-06-07 14:01:39 +0000
+++ b/include/service_versions.h	2011-03-30 14:22:50 +0000
@@ -23,3 +23,4 @@
 #define VERSION_thd_alloc       0x0100
 #define VERSION_thd_wait        0x0100
 #define VERSION_my_thread_scheduler 0x0100
+#define VERSION_heap_alloc      0x0100

=== modified file 'libservices/CMakeLists.txt'
--- a/libservices/CMakeLists.txt	2010-11-13 22:16:52 +0000
+++ b/libservices/CMakeLists.txt	2011-03-30 14:22:50 +0000
@@ -19,7 +19,8 @@ SET(MYSQLSERVICES_SOURCES
   my_snprintf_service.c
   thd_alloc_service.c
   thd_wait_service.c
-  my_thread_scheduler_service.c)
+  my_thread_scheduler_service.c
+  heap_alloc_service.c)
 
 ADD_LIBRARY(mysqlservices ${MYSQLSERVICES_SOURCES})
 INSTALL(TARGETS mysqlservices DESTINATION ${INSTALL_LIBDIR} COMPONENT Development)

=== added file 'libservices/heap_alloc_service.c'
--- a/libservices/heap_alloc_service.c	1970-01-01 00:00:00 +0000
+++ b/libservices/heap_alloc_service.c	2011-03-30 14:22:50 +0000
@@ -0,0 +1,17 @@
+/* Copyright (C) 2009 Sun Microsystems, Inc.
+
+   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; version 2 of the License.
+
+   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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#include <service_versions.h>
+SERVICE_VERSION *heap_alloc_service= (void*)VERSION_heap_alloc;

=== modified file 'sql/sql_plugin_services.h'
--- a/sql/sql_plugin_services.h	2010-06-07 14:01:39 +0000
+++ b/sql/sql_plugin_services.h	2011-03-30 14:22:50 +0000
@@ -46,6 +46,12 @@ static struct my_thread_scheduler_servic
   my_thread_scheduler_reset,
 };
 
+static struct heap_alloc_service_st heap_alloc_handler= {
+  my_malloc,
+  my_free,
+  my_realloc,
+};
+
 
 static struct st_service_ref list_of_services[]=
 {
@@ -54,5 +60,6 @@ static struct st_service_ref list_of_ser
   { "thd_wait_service",    VERSION_thd_wait,    &thd_wait_handler },
   { "my_thread_scheduler_service",
     VERSION_my_thread_scheduler, &my_thread_scheduler_handler },
+  { "heap_alloc_service",   VERSION_heap_alloc,   &heap_alloc_handler },
 };
 


Attachment: [text/bzr-bundle] bzr/rafal.somla@oracle.com-20110330142250-tn7sdly9e8tnrir5.bundle
Thread
bzr commit into mysql-5.5 branch (rafal.somla:3376) Rafal Somla30 Mar
  • Re: bzr commit into mysql-5.5 branch (rafal.somla:3376)Sergei Golubchik2 Apr
    • Re: bzr commit into mysql-5.5 branch (rafal.somla:3376)Paul DuBois4 Apr