1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 09:58:01 +00:00
putty-source/contrib/cygtermd/malloc.c
Simon Tatham b642aa086a Add a directory 'contrib/cygtermd', containing the source code for my
hacky helper program to let PuTTY act as a local pterm-oid on
Cygwin-enabled Windows systems.

[originally from svn r9191]
2011-07-10 14:22:32 +00:00

44 lines
608 B
C

/*
* malloc.c: implementation of malloc.h
*/
#include <stdlib.h>
#include <string.h>
#include "malloc.h"
extern void fatal(const char *, ...);
void *smalloc(size_t size) {
void *p;
p = malloc(size);
if (!p) {
fatal("out of memory");
}
return p;
}
void sfree(void *p) {
if (p) {
free(p);
}
}
void *srealloc(void *p, size_t size) {
void *q;
if (p) {
q = realloc(p, size);
} else {
q = malloc(size);
}
if (!q)
fatal("out of memory");
return q;
}
char *dupstr(const char *s) {
char *r = smalloc(1+strlen(s));
strcpy(r,s);
return r;
}