mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-02 03:52:49 -05:00
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]
This commit is contained in:
43
contrib/cygtermd/malloc.c
Normal file
43
contrib/cygtermd/malloc.c
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
Reference in New Issue
Block a user