links

lynx-like text mode web browser
git clone anongit@rnpnr.xyz:links.git
Log | Files | Refs | Feed | README | LICENSE

error.c (621B)


      1 /* error.c
      2  * (c) 2002 Mikulas Patocka
      3  * This file is a part of the Links program, released under GPL.
      4  */
      5 
      6 #include "links.h"
      7 
      8 void *
      9 mem_calloc(size_t size)
     10 {
     11 	void *p;
     12 	if (!size)
     13 		return NULL;
     14 	if (!(p = calloc(1, size)))
     15 		die("calloc: %s\n", strerror(errno));
     16 	return p;
     17 }
     18 
     19 unsigned char *
     20 memacpy(const unsigned char *src, size_t len)
     21 {
     22 	unsigned char *m;
     23 	if (!(len + 1))
     24 		overalloc();
     25 	m = xmalloc(len + 1);
     26 	if (len)
     27 		memcpy(m, src, len);
     28 	m[len] = 0;
     29 	return m;
     30 }
     31 
     32 unsigned char *
     33 stracpy(const unsigned char *src)
     34 {
     35 	return src ? memacpy(src, src != DUMMY ? strlen((char *)src) : 0)
     36 	           : NULL;
     37 }