|
Packit |
8f70b4 |
/*
|
|
Packit |
8f70b4 |
* lftp - file transfer program
|
|
Packit |
8f70b4 |
*
|
|
Packit |
8f70b4 |
* Copyright (c) 1996-2016 by Alexander V. Lukyanov (lav@yars.free.net)
|
|
Packit |
8f70b4 |
*
|
|
Packit |
8f70b4 |
* This program is free software; you can redistribute it and/or modify
|
|
Packit |
8f70b4 |
* it under the terms of the GNU General Public License as published by
|
|
Packit |
8f70b4 |
* the Free Software Foundation; either version 3 of the License, or
|
|
Packit |
8f70b4 |
* (at your option) any later version.
|
|
Packit |
8f70b4 |
*
|
|
Packit |
8f70b4 |
* This program is distributed in the hope that it will be useful,
|
|
Packit |
8f70b4 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
8f70b4 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
8f70b4 |
* GNU General Public License for more details.
|
|
Packit |
8f70b4 |
*
|
|
Packit |
8f70b4 |
* You should have received a copy of the GNU General Public License
|
|
Packit |
8f70b4 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
8f70b4 |
*/
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
#ifndef XMALLOC_H
|
|
Packit |
8f70b4 |
#define XMALLOC_H
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
#include <stdlib.h>
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
#ifdef DBMALLOC
|
|
Packit |
8f70b4 |
#include "dbmalloc.h"
|
|
Packit |
8f70b4 |
#endif
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
void *xmalloc(size_t);
|
|
Packit |
8f70b4 |
void *xrealloc(void *,size_t);
|
|
Packit |
8f70b4 |
char *xstrdup(const char *s,int spare=0);
|
|
Packit |
8f70b4 |
char *xstrset(char *&mem,const char *s);
|
|
Packit |
8f70b4 |
char *xstrset(char *&mem,const char *s,size_t n);
|
|
Packit |
8f70b4 |
#define alloca_strdup(s) alloca_strdup2((s),0)
|
|
Packit |
8f70b4 |
#define alloca_strdup2(s,n) (strcpy((char*)alloca(strlen((s))+1+(n)),(s)))
|
|
Packit |
8f70b4 |
#define alloca_append(s1,s2) strcat(alloca_strdup2((s1),strlen((s2))),(s2));
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
void xfree(void *p);
|
|
Packit |
8f70b4 |
void xmalloc_register_block(void *);
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
#include "xstring.h"
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
static inline void *xmemdup(const void *m,int len)
|
|
Packit |
8f70b4 |
{
|
|
Packit |
8f70b4 |
if(!m) return 0;
|
|
Packit |
8f70b4 |
void *buf=xmalloc(len);
|
|
Packit |
8f70b4 |
memcpy(buf,m,len);
|
|
Packit |
8f70b4 |
return buf;
|
|
Packit |
8f70b4 |
}
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
#endif /* XMALLOC_H */
|