File: realloc.c

package info (click to toggle)
di 4.18-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 368 kB
  • ctags: 394
  • sloc: ansic: 4,933; sh: 1,352; perl: 1,004; makefile: 174
file content (49 lines) | stat: -rw-r--r-- 782 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * $Id: realloc.c,v 1.3 2009-11-23 11:25:10-08 bll Exp $
 * $Source: /home/bll/DI/RCS/realloc.c,v $
 * Copyright 1994-2009 Brad Lanam, Walnut Creek, CA
 */

#include "config.h"
#include "di.h"

#include <stdio.h>
#if _hdr_stdlib
# include <stdlib.h>
#endif
#if _hdr_memory
# include <memory.h>
#endif
#if _include_malloc && _hdr_malloc
# include <malloc.h>
#endif

/*
 * Realloc
 *
 * portable realloc
 * some variants don't accept a null pointer for initial allocation.
 *
 */

void *
#if _proto_stdc
Realloc (void *ptr, Size_t size)
#else
Realloc (ptr, size)
    void        *ptr;
    Size_t      size;
#endif
{
    if (ptr == (void *) NULL)
    {
        ptr = (void *) malloc (size);
    }
    else
    {
        ptr = (void *) realloc (ptr, size);
    }

    return ptr;
}