OpenCores
URL https://opencores.org/ocsvn/igor/igor/trunk

Subversion Repositories igor

[/] [igor/] [trunk/] [simulator/] [alloc.c] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 atypic
/*
2
 * Copyright (c) 2007 Eirik A. Nygaard <eirikald@pvv.ntnu.no>
3
 *
4
 * Permission is hereby granted, free of charge, to any person obtaining a copy
5
 * of this software and associated documentation files (the "Software"), to
6
 * deal in the Software without restriction, including without limitation the
7
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8
 * sell copies of the Software, and to permit persons to whom the Software is
9
 * furnished to do so, subject to the following conditions:
10
 *
11
 * The above copyright notice and this permission notice shall be included in
12
 * all copies or substantial portions of the Software.
13
 *
14
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20
 * IN THE SOFTWARE.
21
 */
22
 
23
#define _GNU_SOURCE
24
#include <stdio.h>
25
#include <string.h>
26
#include <stdlib.h>
27
#include <stdarg.h>
28
#include <err.h>
29
 
30
void *
31
sstrdup(char *buf)
32
{
33
        void *p;
34
 
35
        p = strdup(buf);
36
        if (p == NULL)
37
                err(1, "sstrdup()");
38
 
39
        return p;
40
}
41
 
42
void *
43
smalloc(size_t s)
44
{
45
        void *p;
46
 
47
        p = malloc(s);
48
        if (p == NULL)
49
                err(1, "smalloc()");
50
        return p;
51
}
52
 
53
void *
54
scalloc(size_t num, size_t size)
55
{
56
        void *p;
57
 
58
        p = calloc(num, size);
59
        if (p == NULL)
60
                err(1, "scalloc()");
61
        return p;
62
}
63
 
64
void *
65
srealloc(void *ptr, size_t size)
66
{
67
        void *p;
68
 
69
        p = realloc(ptr, size);
70
        if (p == NULL)
71
                err(1, "srealloc()");
72
        return p;
73
}
74
 
75
int
76
sasprintf(char **strp, const char *fmt, ...)
77
{
78
        va_list ap;
79
        int i;
80
 
81
        va_start(ap, fmt);
82
        i = vasprintf(strp, fmt, ap);
83
        va_end(ap);
84
 
85
        if (i == -1)
86
                err(1, "sasprintf()");
87
 
88
        return i;
89
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.