2001-02-17 14:19:19 +02:00
|
|
|
/***********************************************************************
|
|
|
|
Memory primitives
|
|
|
|
|
|
|
|
(c) 1994, 1995 Innobase Oy
|
|
|
|
|
|
|
|
Created 5/30/1994 Heikki Tuuri
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef ut0mem_h
|
|
|
|
#define ut0mem_h
|
|
|
|
|
2001-04-20 15:18:46 +03:00
|
|
|
#include "univ.i"
|
2001-02-17 14:19:19 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2001-10-10 22:47:08 +03:00
|
|
|
/* The total amount of memory currently allocated from the OS with malloc */
|
|
|
|
extern ulint ut_total_allocated_memory;
|
|
|
|
|
2001-02-17 14:19:19 +02:00
|
|
|
UNIV_INLINE
|
|
|
|
void*
|
|
|
|
ut_memcpy(void* dest, void* sour, ulint n);
|
|
|
|
|
|
|
|
UNIV_INLINE
|
|
|
|
void*
|
|
|
|
ut_memmove(void* dest, void* sour, ulint n);
|
|
|
|
|
|
|
|
UNIV_INLINE
|
|
|
|
int
|
|
|
|
ut_memcmp(void* str1, void* str2, ulint n);
|
|
|
|
|
|
|
|
|
2001-09-20 21:04:48 +03:00
|
|
|
/**************************************************************************
|
|
|
|
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
|
|
|
|
defined and set_to_zero is TRUE. */
|
|
|
|
|
2001-02-17 14:19:19 +02:00
|
|
|
void*
|
2001-09-20 21:04:48 +03:00
|
|
|
ut_malloc_low(
|
|
|
|
/*==========*/
|
|
|
|
/* out, own: allocated memory */
|
|
|
|
ulint n, /* in: number of bytes to allocate */
|
|
|
|
ibool set_to_zero); /* in: TRUE if allocated memory should be set
|
|
|
|
to zero if UNIV_SET_MEM_TO_ZERO is defined */
|
|
|
|
/**************************************************************************
|
|
|
|
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
|
|
|
|
defined. */
|
|
|
|
|
|
|
|
void*
|
|
|
|
ut_malloc(
|
|
|
|
/*======*/
|
|
|
|
/* out, own: allocated memory */
|
|
|
|
ulint n); /* in: number of bytes to allocate */
|
|
|
|
/**************************************************************************
|
2003-01-12 23:58:56 +02:00
|
|
|
Tests if malloc of n bytes would succeed. ut_malloc() asserts if memory runs
|
|
|
|
out. It cannot be used if we want to return an error message. Prints to
|
|
|
|
stderr a message if fails. */
|
|
|
|
|
|
|
|
ibool
|
|
|
|
ut_test_malloc(
|
|
|
|
/*===========*/
|
|
|
|
/* out: TRUE if succeeded */
|
|
|
|
ulint n); /* in: try to allocate this many bytes */
|
|
|
|
/**************************************************************************
|
2001-09-20 21:04:48 +03:00
|
|
|
Frees a memory bloock allocated with ut_malloc. */
|
|
|
|
|
|
|
|
void
|
|
|
|
ut_free(
|
|
|
|
/*====*/
|
|
|
|
void* ptr); /* in, own: memory block */
|
|
|
|
/**************************************************************************
|
2003-06-15 01:04:28 +03:00
|
|
|
Frees in shutdown all allocated memory not freed yet. */
|
2001-02-17 14:19:19 +02:00
|
|
|
|
|
|
|
void
|
2001-09-20 21:04:48 +03:00
|
|
|
ut_free_all_mem(void);
|
|
|
|
/*=================*/
|
2001-02-17 14:19:19 +02:00
|
|
|
|
|
|
|
UNIV_INLINE
|
|
|
|
char*
|
|
|
|
ut_strcpy(char* dest, char* sour);
|
|
|
|
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
2002-07-23 18:31:22 +03:00
|
|
|
ut_strlen(const char* str);
|
2001-02-17 14:19:19 +02:00
|
|
|
|
|
|
|
UNIV_INLINE
|
|
|
|
int
|
|
|
|
ut_strcmp(void* str1, void* str2);
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
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 */
|
Many files:
Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication
sync0sync.c:
UNIV_SYNC_DEBUG caused assertion in the creation of the doublewrite buffer, if we do not allow thousands of latches per thread
innobase/dict/dict0crea.c:
Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication
innobase/dict/dict0dict.c:
Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication
innobase/include/dict0crea.h:
Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication
innobase/include/dict0dict.h:
Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication
innobase/include/ut0mem.h:
Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication
innobase/row/row0mysql.c:
Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication
innobase/sync/sync0sync.c:
UNIV_SYNC_DEBUG caused assertion in the creation of the doublewrite buffer, if we do not allow thousands of latches per thread
innobase/ut/ut0mem.c:
Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication
2004-02-09 01:32:00 +02:00
|
|
|
/**************************************************************************
|
2004-03-16 20:55:49 +02:00
|
|
|
Return a copy of the given string. The returned string must be freed
|
|
|
|
using mem_free. */
|
|
|
|
|
|
|
|
char*
|
|
|
|
ut_strdup(
|
|
|
|
/*======*/
|
|
|
|
/* out, own: cnull-terminated string */
|
|
|
|
char* str); /* in: null-terminated string */
|
|
|
|
/**************************************************************************
|
Many files:
Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication
sync0sync.c:
UNIV_SYNC_DEBUG caused assertion in the creation of the doublewrite buffer, if we do not allow thousands of latches per thread
innobase/dict/dict0crea.c:
Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication
innobase/dict/dict0dict.c:
Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication
innobase/include/dict0crea.h:
Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication
innobase/include/dict0dict.h:
Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication
innobase/include/ut0mem.h:
Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication
innobase/row/row0mysql.c:
Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication
innobase/sync/sync0sync.c:
UNIV_SYNC_DEBUG caused assertion in the creation of the doublewrite buffer, if we do not allow thousands of latches per thread
innobase/ut/ut0mem.c:
Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication
2004-02-09 01:32:00 +02:00
|
|
|
Checks if a null-terminated string contains a certain character. */
|
|
|
|
|
|
|
|
ibool
|
|
|
|
ut_str_contains(
|
|
|
|
/*============*/
|
|
|
|
char* str, /* in: null-terminated string */
|
|
|
|
char c); /* in: character */
|
2001-02-17 14:19:19 +02:00
|
|
|
|
|
|
|
#ifndef UNIV_NONINL
|
|
|
|
#include "ut0mem.ic"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|