/* * Copyright (C) 2017 Barcelona Supercomputing Center * Centro Nacional de Supercomputacion * * This file is part of the Data Scheduler, a daemon for tracking and managing * requests for asynchronous data transfer in a hierarchical storage environment. * * See AUTHORS file in the top level directory for information * regarding developers and contributors. * * The Data Scheduler is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Data Scheduler is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Data Scheduler. If not, see . */ #include #include #include "xmalloc.h" #include "xstring.h" char* xstrdup(const char* str) { size_t sz; char* res; if(str == NULL) { return NULL; } sz = strlen(str) + 1; res = (char*) xmalloc(sz); strncpy(res, str, sz); res[sz] = '\0'; return res; }