src/compat.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Sat, 13 Dec 2008 15:40:23 +0100
changeset 13 d3554afaa768
child 49 59b09b0aeb96
permissions -rw-r--r--
mcbot-0.94-5 Changelog Compat.c added: * provides a safe strdup replacement * snprintf and fdopen may follow... garbage_collection improved Nasty compiler warning removed in parse.c committer: Markus Bröker <mbroeker@largo.homelinux.org>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     1
/**
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     2
 *  $Id: config.c 171 2008-08-10 18:20:39Z mbroeker $
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     3
 * $URL: http://localhost/svn/c/mcbot/trunk/src/compat.c $
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     4
 *
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     5
 */
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     6
#include <stdio.h>
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     7
#include <stdlib.h>
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     8
#include <string.h>
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     9
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    10
#include <compat.h>
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    11
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    12
char *compat_strdup (const char *s)
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    13
{
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    14
    char *buf;
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    15
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    16
    buf = malloc (strlen (s) + 1);
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    17
    if (buf != NULL)
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    18
        strcpy (buf, s);
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    19
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    20
    return buf;
d3554afaa768 mcbot-0.94-5 Changelog
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    21
}