~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/ut/ut0mem.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
290
290
#endif /* !UNIV_HOTBACKUP */
291
291
 
292
292
/**********************************************************************//**
293
 
Frees a memory block allocated with ut_malloc. */
 
293
Frees a memory block allocated with ut_malloc. Freeing a NULL pointer is
 
294
a nop. */
294
295
UNIV_INTERN
295
296
void
296
297
ut_free(
300
301
#ifndef UNIV_HOTBACKUP
301
302
        ut_mem_block_t* block;
302
303
 
303
 
        if (UNIV_LIKELY(srv_use_sys_malloc)) {
 
304
        if (ptr == NULL) {
 
305
                return;
 
306
        } else if (UNIV_LIKELY(srv_use_sys_malloc)) {
304
307
                free(ptr);
305
308
                return;
306
309
        }
486
489
        return(src_size);
487
490
}
488
491
 
489
 
/**********************************************************************//**
490
 
Make a quoted copy of a NUL-terminated string.  Leading and trailing
491
 
quotes will not be included; only embedded quotes will be escaped.
492
 
See also ut_strlenq() and ut_memcpyq().
493
 
@return pointer to end of dest */
494
 
UNIV_INTERN
495
 
char*
496
 
ut_strcpyq(
497
 
/*=======*/
498
 
        char*           dest,   /*!< in: output buffer */
499
 
        char            q,      /*!< in: the quote character */
500
 
        const char*     src)    /*!< in: null-terminated string */
501
 
{
502
 
        while (*src) {
503
 
                if ((*dest++ = *src++) == q) {
504
 
                        *dest++ = q;
505
 
                }
506
 
        }
507
 
 
508
 
        return(dest);
509
 
}
510
 
 
511
 
/**********************************************************************//**
512
 
Make a quoted copy of a fixed-length string.  Leading and trailing
513
 
quotes will not be included; only embedded quotes will be escaped.
514
 
See also ut_strlenq() and ut_strcpyq().
515
 
@return pointer to end of dest */
516
 
UNIV_INTERN
517
 
char*
518
 
ut_memcpyq(
519
 
/*=======*/
520
 
        char*           dest,   /*!< in: output buffer */
521
 
        char            q,      /*!< in: the quote character */
522
 
        const char*     src,    /*!< in: string to be quoted */
523
 
        ulint           len)    /*!< in: length of src */
524
 
{
525
 
        const char*     srcend = src + len;
526
 
 
527
 
        while (src < srcend) {
528
 
                if ((*dest++ = *src++) == q) {
529
 
                        *dest++ = q;
530
 
                }
531
 
        }
532
 
 
533
 
        return(dest);
534
 
}
535
 
 
536
492
#ifndef UNIV_HOTBACKUP
537
493
/**********************************************************************//**
538
494
Return the number of times s2 occurs in s1. Overlapping instances of s2