-/*
- * Copyright (C) 2004-2008 Andre Noll <maan@systemlinux.org>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
-
-/** \file string.c Memory allocation and string handling functions. */
-
-#include "log.h"
-#include "string.h"
-
-#include <sys/time.h> /* gettimeofday */
-#include <pwd.h>
-#include <sys/utsname.h> /* uname() */
-#include <string.h>
-
-#include "error.h"
-
-/**
- * Paraslash's version of malloc().
- *
- * \param size The desired new size.
- *
- * A wrapper for malloc(3) which exits on errors.
- *
- * \return A pointer to the allocated memory, which is suitably aligned for any
- * kind of variable.
- *
- * \sa malloc(3).
- */
-__must_check __malloc void *para_malloc(size_t size)
-{
- assert(size);
- void *p = malloc(size);
-
- if (!p) {
- EMERG_LOG("malloc failed (size = %zu), aborting\n",
- size);
- exit(EXIT_FAILURE);
- }
- return p;
-}
-
-/**
- * Paraslash's version of calloc().
- *
- * \param size The desired new size.
- *
- * A wrapper for calloc(3) which exits on errors.
- *
- * \return A pointer to the allocated and zeroed-out memory, which is suitably
- * aligned for any kind of variable.
- *
- * \sa calloc(3)
- */
-__must_check __malloc void *para_calloc(size_t size)
-{
- void *ret = para_malloc(size);
-
- memset(ret, 0, size);
- return ret;
-}
-
-/**
- * Paraslash's version of strdup().
- *
- * \param s The string to be duplicated.
- *
- * A wrapper for strdup(3). It calls \p exit(EXIT_FAILURE) on errors, i.e.
- * there is no need to check the return value in the caller.
- *
- * \return A pointer to the duplicated string. If \p s was the NULL pointer,
- * an pointer to an empty string is returned.
- *
- * \sa strdup(3)
- */
-__must_check __malloc char *para_strdup(const char *s)
-{
- char *ret;
-
- if ((ret = strdup(s? s: "")))
- return ret;
- EMERG_LOG("strdup failed, aborting\n");
- exit(EXIT_FAILURE);
-}