lessfs  1.7.0
About: Lessfs is a inline data deduplicating file system for Linux (implemented in user space with FUSE; especially useful for backup purposes).
  Fossies Dox: lessfs-1.7.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

lib_safe.c
Go to the documentation of this file.
1 /*
2  * Lessfs: A data deduplicating filesystem.
3  * Copyright (C) 2008 Mark Ruijter <mruijter@lessfs.com>
4  *
5  * This program is free software.
6  * You can redistribute lessfs and/or modify it under the terms of either
7  * (1) the GNU General Public License; either version 3 of the License,
8  * or (at your option) any later version as published by
9  * the Free Software Foundation; or (2) obtain a commercial license
10  * by contacting the Author.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15  * the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */
21 #define _XOPEN_SOURCE 500
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25 #ifndef LFATAL
26 #include "lib_log.h"
27 #endif
28 
29 #include <malloc.h>
30 #include <unistd.h>
31 #include <stdlib.h>
32 #include <stdint.h>
33 #include <stdio.h>
34 #include <string.h>
35 #include <errno.h>
36 #include <sys/types.h>
37 #include <sys/stat.h>
38 #include <sys/file.h>
39 #include <stdarg.h>
40 #include <fcntl.h>
41 #include <dirent.h>
42 #include <sys/stat.h>
43 #include <sys/time.h>
44 #include <unistd.h>
45 #include <signal.h>
46 #include <libgen.h>
47 #include <pthread.h>
48 #include "retcodes.h"
49 #include "lib_safe.h"
50 #include "lib_net.h"
51 
52 #ifdef MEMTRACE
53 #include <tcutil.h>
54 static pthread_mutex_t mem_mutex = PTHREAD_MUTEX_INITIALIZER;
55 TCTREE *memtracetree = NULL;
56 #endif
57 #ifdef FILELOG
58 static pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER;
59 #endif
60 
61 /* Standard read and write routines */
62 
63 static pthread_mutex_t pwrite_mutex = PTHREAD_MUTEX_INITIALIZER;
64 
65 #ifdef FILELOG
66 void wfile_log(char *logfile, char *file, unsigned int line, const char *fmt, ...)
67 {
68  time_t i=0;
69  char *basestr;
70  char *logstr;
71  int pid;
72  char *thetime;
73  int logfp;
74  va_list ap;
75  char *tbuf;
76 
77  pthread_mutex_lock(&log_mutex);
78  pid=getpid();
79  logfp=s_open2(logfile,O_RDWR | O_APPEND | O_CREAT, 0777);
80  if (logfp <= 0) return;
81  logstr=s_zmalloc(1024);
82  va_start(ap, fmt);
83  vsnprintf(logstr,1023,fmt, ap);
84  tbuf=s_zmalloc(30);
85  i=time(NULL);
86  ctime_r(&i,tbuf);
87  thetime=as_sprintf(__FILE__, __LINE__,tbuf);
88  s_free(tbuf);
89  thetime[strlen(thetime)-1]=0;
90  basestr=as_sprintf(__FILE__, __LINE__,"FILE %s - LINE %i - PID %i : %s - ",file,line,pid, thetime);
91  fullWrite(logfp,(unsigned char *)basestr,strlen(basestr));
92  fullWrite(logfp,(unsigned char *)logstr,strlen(logstr));
93  fullWrite(logfp,(unsigned char *)"\n",1);
94  fsync(logfp);
95  s_free(thetime);
96  s_free(logstr);
97  s_free(basestr);
98  close(logfp);
99  pthread_mutex_unlock(&log_mutex);
100 }
101 #endif
102 
103 int s_read(int fd, unsigned char *buf, int len)
104 {
105  int total;
106  int thistime;
107 
108  for (total = 0; total < len;) {
109  thistime = read(fd, buf + total, len - total);
110 
111  if (thistime < 0) {
112  if (EINTR == errno || EAGAIN == errno)
113  continue;
114  return -1;
115  } else if (thistime == 0) {
116  /* EOF, but we didn't read the minimum. return what we've read
117  * so far and next read (if there is one) will return 0. */
118  return total;
119  }
120  total += thistime;
121  }
122  return total;
123 }
124 
125 int s_pread(int fd, void *buf, size_t len, off_t off)
126 {
127  int total;
128  int thistime;
129  off_t thisoffset;
130 
131  thisoffset = off;
132  for (total = 0; total < len;) {
133  thistime = pread(fd, buf + total, len - total, thisoffset);
134  if (thistime < 0) {
135  if (EINTR == errno || EAGAIN == errno)
136  continue;
137  return -1;
138  } else if (thistime == 0) {
139  /* EOF, but we didn't read the minimum. return what we've read
140  * so far and next read (if there is one) will return 0. */
141  return total;
142  }
143  total += thistime;
144  thisoffset += total;
145  }
146  return total;
147 }
148 
149 int s_lckpread(int fd, void *buf, size_t len, off_t off)
150 {
151  int total;
152  pthread_mutex_lock(&pwrite_mutex);
153  total = s_pread(fd, buf, len, off);
154  pthread_mutex_unlock(&pwrite_mutex);
155  return total;
156 }
157 
158 int s_write(int fd, const unsigned char *buf, int len)
159 {
160  int total;
161  int thistime;
162 
163  for (total = 0; total < len;) {
164  thistime = write(fd, buf + total, len - total);
165 
166  if (thistime < 0) {
167  if (EINTR == errno || EAGAIN == errno)
168  continue;
169  return thistime; /* always an error for writes */
170  }
171  total += thistime;
172  }
173  return total;
174 }
175 
176 int s_pwrite(int fd, const void *buf, size_t len, off_t off)
177 {
178  int total;
179  int thistime;
180  off_t thisoff;
181 
182  thisoff = off;
183  for (total = 0; total < len;) {
184  thistime = pwrite(fd, buf + total, len - total, thisoff);
185 
186  if (thistime < 0) {
187  if (EINTR == errno || EAGAIN == errno)
188  continue;
189  return thistime; /* always an error for writes */
190  }
191  total += thistime;
192  thisoff += total;
193  }
194  return total;
195 }
196 
197 
198 int s_lckpwrite(int fd, const void *buf, size_t len, off_t off)
199 {
200  int total;
201  pthread_mutex_lock(&pwrite_mutex);
202  total = s_pwrite(fd, buf, len, off);
203  pthread_mutex_unlock(&pwrite_mutex);
204  return total;
205 }
206 
207 void tstamp()
208 {
209  struct timeval tv;
210  gettimeofday(&tv, NULL);
211  LDEBUG("Entering function : %s : %lu:%lu", function, tv.tv_sec,
212  tv.tv_usec);
213 }
214 
215 void estamp()
216 {
217  struct timeval tv;
218  gettimeofday(&tv, NULL);
219  LDEBUG("Exit function : %s : %lu:%lu", function, tv.tv_sec,
220  tv.tv_usec);
221 }
222 
223 void exitFunc()
224 {
225  static int breekijzer = 0;
226  pid_t apid;
227 
228  apid = getpid();
229  if (0 == breekijzer) {
230  kill(apid, SIGUSR1);
231  breekijzer++;
232  } else
233  exit(EXIT_SYSTEM);
234 }
235 
236 #ifdef MEMTRACE
237 void memdeeptrace(void *addr, size_t size)
238 {
239  char *key;
240  char *val;
241  int ksize;
242  int vsize;
243  MEMINFO *meminfo=NULL;
244 
245  tctreeiterinit(memtracetree);
246  while (key = (char *) tctreeiternext(memtracetree, &ksize)) {
247  val =
248  (char *) tctreeget(memtracetree, (void *) key, ksize, &vsize);
249  if (val) {
250  meminfo = (MEMINFO *) val;
251  }
252  if (meminfo->address > addr + size)
253  continue;
254  if (meminfo->address + meminfo->size < addr)
255  continue;
256  LINFO
257  ("memdeeptrace addr %lu - size %lu overlaps with meminfo->address %lu size %u filename %s, line %u",
258  (unsigned long) addr, size, meminfo->address, meminfo->size,
259  meminfo->filename, meminfo->line);
260  }
261 }
262 
263 void addmem(void *addr, size_t size, char *file, unsigned int line)
264 {
265  MEMINFO meminfo;
266  pthread_mutex_lock(&mem_mutex);
267  if (NULL == memtracetree)
268  memtracetree = tctreenew();
269  snprintf(meminfo.filename, sizeof(meminfo.filename), "%s", file);
270  meminfo.size = size;
271  meminfo.address = (uintptr_t) addr;
272  meminfo.line = line;
273  memdeeptrace(addr, size);
274  tctreeput(memtracetree, &meminfo.address, sizeof(uintptr_t), &meminfo,
275  sizeof(MEMINFO));
276  pthread_mutex_unlock(&mem_mutex);
277 }
278 
279 int delmem(void *addr, char *file, unsigned int line)
280 {
281  int ret=0;
282  uintptr_t p;
283  const char *dta;
284  int size;
285 
286  p = (uintptr_t) addr;
287  pthread_mutex_lock(&mem_mutex);
288  dta = tctreeget(memtracetree, (void *) &p, sizeof(uintptr_t), &size);
289  if (dta) {
290  ret = tctreeout(memtracetree, (void *) &p, sizeof(uintptr_t));
291  }
292  pthread_mutex_unlock(&mem_mutex);
293  return (ret);
294 }
295 #endif
296 
297 
298 void *x_malloc(size_t size, char *file, unsigned int line)
299 {
300  void *retval;
301 
302  retval = malloc(size);
303  if (!retval)
304  ERRHANDLE("Out of memory : malloc failed on alloc %lu bytes.\n",
305  (unsigned long) size);
306 #ifdef MEMTRACE
307  addmem(retval, size, file, line);
308 #endif
309  return retval;
310 }
311 
312 
313 void *bdb_malloc(size_t size)
314 {
315  void *retval;
316 
317  retval = malloc(size);
318  if (!retval)
319  ERRHANDLE("Out of memory : malloc failed on alloc %lu bytes.\n",
320  (unsigned long) size);
321 #ifdef MEMTRACE
322  addmem(retval, size, "DBD", 1);
323 #endif
324  return retval;
325 }
326 
327 void bdb_free(void *mem)
328 {
329 #ifdef MEMTRACE
330  if (!delmem(mem, __FILE__, __LINE__))
331  LINFO("Err free %s : %u", "BDB", 1);
332 #endif
333  free(mem);
334 }
335 
336 
337 void x_free(void *mem, char *file, unsigned int line)
338 {
339 #ifdef MEMTRACE
340  if (!delmem(mem, file, line))
341  LINFO("Err free %s : %u", file, line);
342 #endif
343  free(mem);
344 }
345 
346 #ifdef MEMTRACE
347 void leak_report()
348 {
349  MEMINFO *meminfo;
350  uintptr_t *p;
351 
352  pthread_mutex_lock(&mem_mutex);
353  FILE *fp_write = fopen("/tmp/lessfs_memleak.txt", "wt");
354  char info[1024];
355  memset(info, 0, 1024);
356  int ksize;
357  int vsize;
358 
359 
360  if (fp_write) {
361  sprintf(info, "%s\n", "Memory Leak Summary");
362  fwrite(info, (strlen(info)), 1, fp_write);
363  sprintf(info, "%s\n", "-----------------------------------");
364  fwrite(info, (strlen(info)), 1, fp_write);
365 
366  tctreeiterinit(memtracetree);
367  while (p = (uintptr_t *) tctreeiternext(memtracetree, &ksize)) {
368  meminfo =
369  (MEMINFO *) tctreeget(memtracetree, (void *) p, ksize,
370  &vsize);
371  sprintf(info, "address : %lu\n", (uintptr_t) meminfo->address);
372  fwrite(info, (strlen(info)), 1, fp_write);
373  sprintf(info, "size : %d bytes\n", meminfo->size);
374  fwrite(info, (strlen(info)), 1, fp_write);
375  sprintf(info, "file : %s\n", meminfo->filename);
376  fwrite(info, (strlen(info)), 1, fp_write);
377  sprintf(info, "line : %d\n", meminfo->line);
378  fwrite(info, (strlen(info)), 1, fp_write);
379  sprintf(info, "%s\n", "-----------------------------------");
380  fwrite(info, (strlen(info)), 1, fp_write);
381  //tctreeout(memtracetree, (void *)p, ksize);
382  }
383  }
384  fflush(fp_write);
385  fclose(fp_write);
386  pthread_mutex_unlock(&mem_mutex);
387 }
388 #endif
389 
390 void *x_zmalloc(size_t size, char *file, unsigned int line)
391 {
392  void *retval;
393 
394  retval = x_malloc(size, file, line);
395  if (!retval)
396  ERRHANDLE("Out of memory : malloc failed on alloc %lu bytes.\n",
397  (unsigned long) size);
398  memset(retval, 0, size);
399  return retval;
400 }
401 
402 char *s_fgets(int size, FILE * stream)
403 {
404  char *s;
405  s = s_malloc(size);
406  if (NULL == fgets(s, size, stream)) {
407  if (!feof(stream)) {
408  ERRHANDLE("fgets failed on reading %i bytes : %s.\n", size,
409  strerror(errno));
410  }
411  }
412  return (s);
413 }
414 
415 int s_link(const char *oldpath, const char *newpath)
416 {
417  int result;
418 
419  result = link(oldpath, newpath);
420  if (-1 == result) {
421  ERRHANDLE("Could not link %s to %s\n", oldpath, newpath);
422  }
423  return (result);
424 }
425 
426 int s_unlink(const char *ppath)
427 {
428  int result;
429 
430  result = unlink(ppath);
431  if (-1 == result) {
432  ERRHANDLE("Could not unlink %s\n", ppath);
433  }
434  return (result);
435 }
436 
437 void s_fputs(const char *s, FILE * stream)
438 {
439  int result;
440 
441  result = fputs(s, stream);
442  if (result == EOF)
443  ERRHANDLE("Disk write error on s_fputs.\n");
444  return;
445 }
446 
447 char *x_strdup(const char *s, char *file, unsigned int line)
448 {
449  char *retval;
450  if (s == NULL)
451  return NULL;
452  retval = strdup(s);
453  if (!retval)
454  ERRHANDLE("Out of memory : strdup failed.\n");
455 #ifdef MEMTRACE
456  addmem(retval, strlen(s) + 1, file, line);
457 #endif
458  return retval;
459 }
460 
461 int s_chdir(const char *chpath)
462 {
463  int result;
464 
465  result = chdir(chpath);
466  if (-1 == result)
467  ERRHANDLE("Failed to chdir to : %s\n", chpath);
468  return result;
469 }
470 
471 FILE *s_fopen(char *path, char *mode)
472 {
473  FILE *retval;
474 
475  retval = fopen(path, mode);
476  if (!retval)
477  ERRHANDLE("fopen %s failed.\n", path);
478  return retval;
479 }
480 
481 int s_open(const char *pathname, int flags)
482 {
483  int retval;
484  if ((retval = open(pathname, flags)) == -1)
485  ERRHANDLE("open %s failed\n", pathname);
486  return retval;
487 }
488 
489 int s_open2(const char *pathname, int flags, mode_t mode)
490 {
491  int retval;
492  if ((retval = open(pathname, flags, mode)) == -1)
493  ERRHANDLE("open %s failed : %s", pathname, strerror(errno));
494  return retval;
495 }
496 
497 void *s_realloc(void *ptr, size_t size)
498 {
499  void *retval;
500 #ifdef MEMTRACE
501  delmem(ptr, __FILE__, __LINE__);
502 #endif
503  retval = realloc(ptr, size);
504  if (!retval)
505  ERRHANDLE("Out of memory : realloc failed.\n");
506 #ifdef MEMTRACE
507  addmem(retval, size, __FILE__, __LINE__);
508 #endif
509  return retval;
510 }
511 
512 
513 void *bdb_realloc(void *ptr, size_t size)
514 {
515  void *retval;
516 #ifdef MEMTRACE
517  delmem(ptr, "BDB", 1);
518 #endif
519  retval = realloc(ptr, size);
520  if (!retval)
521  ERRHANDLE("Out of memory : realloc failed.\n");
522 #ifdef MEMTRACE
523  addmem(retval, size, "BDB", 1);
524 #endif
525  return retval;
526 }
527 
528 char *as_strcat(char *dest, const char *src)
529 {
530  int srclen;
531  int destlen;
532  char *retstr = NULL;
533 
534  srclen = strlen(src);
535  destlen = strlen(dest);
536 
537  retstr = s_malloc(srclen + destlen + 1);
538  memset(retstr, 0, srclen + destlen + 1);
539  memcpy(retstr, dest, destlen);
540  memcpy(retstr + destlen, src, srclen);
541 
542  return (retstr);
543 }
544 
545 char *as_strarrcat(const char **strarr, ssize_t count)
546 {
547  int totallen = 0;
548  int i;
549  char *retstr = NULL, *curpos;
550 
551  for (i = 0; i < count; i++) {
552  totallen += strlen(strarr[i]);
553  }
554 
555  curpos = retstr = s_zmalloc(totallen + 1);
556  for (i = 0; i < count; i++) {
557  strcpy(curpos, strarr[i]);
558  curpos += strlen(strarr[i]);
559  }
560 
561  return retstr;
562 }
563 
564 void *as_sprintf(char *file, unsigned int line, const char *fmt, ...)
565 {
566  /* Guess we need no more than 100 bytes. */
567  int n, size = 100;
568  void *p;
569  va_list ap;
570  p = x_malloc(size, file, line);
571  while (1) {
572  /* Try to print in the allocated space. */
573  va_start(ap, fmt);
574  n = vsnprintf(p, size, fmt, ap);
575  va_end(ap);
576  /* If that worked, return the string. */
577  if (n > -1 && n < size)
578  return p;
579  /* Else try again with more space. */
580  if (n > -1) /* glibc 2.1 */
581  size = n + 1; /* precisely what is needed */
582  else /* glibc 2.0 */
583  size *= 2; /* twice the old size */
584  p = s_realloc(p, size);
585  }
586 }
587 
588 int compare_elements(const void **p1, const void **p2)
589 {
590  return strcoll(*p1, *p2);
591 }
592 
593 char **s_srtOpenDir(char *processDir)
594 {
595  DIR *dp = NULL;
596  struct dirent *entry;
597  int pcount = 0;
598  int len;
599  unsigned int allocated = 0;
600  char **sortme;
601  struct stat stbuf;
602 
603  if (NULL == (dp = (opendir(processDir)))) {
604  ERRHANDLE("opendir %s failed in s_srtOpendir.\n", processDir);
605  }
606  pcount = 0;
607  allocated = 0;
608  sortme = (char **) s_malloc(sizeof(char *));
609  while (entry = readdir(dp)) {
610  if (-1 == stat(entry->d_name, &stbuf)) {
611  continue;
612  }
613  if (S_ISDIR(stbuf.st_mode)) {
614  continue;
615  }
616  len = strlen(entry->d_name) + 1;
617  allocated = allocated + len;
618  sortme[pcount] = s_malloc(len);
619  sprintf(sortme[pcount], "%s", entry->d_name);
620  pcount++;
621  len = allocated + sizeof(char *);
622  allocated = len;
623  sortme = (char **) s_realloc(sortme, allocated);
624  }
625  closedir(dp);
626  sortme[pcount] = NULL;
627  qsort(sortme, pcount, sizeof(char *), (void *) compare_elements);
628  return sortme;
629 }
630 
631 int dirCnt(char *processDir)
632 {
633  int count = 0;
634  DIR *dp = NULL;
635  struct dirent *entry;
636  struct stat stbuf;
637 
638  if (NULL == (dp = (opendir(processDir)))) {
639  ERRHANDLE("opendir %s failed in dirCnt\n", processDir);
640  }
641  while (entry = readdir(dp)) {
642  if (-1 == stat(entry->d_name, &stbuf)) {
643  continue;
644  }
645  if (S_ISDIR(stbuf.st_mode)) {
646  continue;
647  }
648  count++;
649  }
650  closedir(dp);
651  return (count);
652 }
653 
654 char *x_basename(char *path, char *file, unsigned int line)
655 {
656  char *tmpstr;
657  char *rdir;
658  char *retstr;
659  tmpstr = s_strdup(path);
660  rdir = basename(tmpstr);
661  retstr = x_strdup(rdir, file, line);
662  s_free(tmpstr);
663  return retstr;
664 }
665 
666 char *x_dirname(char *path, char *file, unsigned int line)
667 {
668  char *tmpstr;
669  char *rdir;
670  char *retstr;
671 
672  if (NULL == path)
673  return NULL;
674  tmpstr = s_strdup(path);
675  rdir = dirname(tmpstr);
676  retstr = x_strdup(rdir, file, line);
677  s_free(tmpstr);
678  return retstr;
679 }
680 
681 int mkpath(const char *s, mode_t mode)
682 {
683  char *q, *r = NULL, *path = NULL, *up = NULL;
684  int rv;
685 
686  if ( s == NULL ) return(0);
687  rv = -1;
688  if (strcmp(s, ".") == 0 || strcmp(s, "/") == 0)
689  return (0);
690 
691  path = s_strdup(s);
692  q = s_strdup(s);
693  r = s_dirname(q);
694  up = s_strdup(r);
695  if ((mkpath(up, mode) == -1) && (errno != EEXIST))
696  goto out;
697  if ((mkdir(path, mode) == -1) && (errno != EEXIST))
698  rv = -1;
699  else
700  rv = 0;
701  out:
702  if (up)
703  free(up);
704  free(q);
705  free(path);
706  free(r);
707  return (rv);
708 }
as_strcat
char * as_strcat(char *dest, const char *src)
Definition: lib_safe.c:528
MEMINFO::filename
char filename[128]
Definition: lib_safe.h:39
lib_safe.h
s_write
int s_write(int fd, const unsigned char *buf, int len)
Definition: lib_safe.c:158
s_unlink
int s_unlink(const char *ppath)
Definition: lib_safe.c:426
s_fgets
char * s_fgets(int size, FILE *stream)
Definition: lib_safe.c:402
MEMINFO::address
unsigned long int address
Definition: lib_safe.h:37
s_link
int s_link(const char *oldpath, const char *newpath)
Definition: lib_safe.c:415
lib_log.h
s_fputs
void s_fputs(const char *s, FILE *stream)
Definition: lib_safe.c:437
fullWrite
int fullWrite(int fd, unsigned char *buf, int len)
Definition: lib_net.c:419
dirCnt
int dirCnt(char *processDir)
Definition: lib_safe.c:631
s_lckpread
int s_lckpread(int fd, void *buf, size_t len, off_t off)
Definition: lib_safe.c:149
compare_elements
int compare_elements(const void **p1, const void **p2)
Definition: lib_safe.c:588
s_open
int s_open(const char *pathname, int flags)
Definition: lib_safe.c:481
as_sprintf
void * as_sprintf(char *file, unsigned int line, const char *fmt,...)
Definition: lib_safe.c:564
s_dirname
#define s_dirname(path)
Definition: lib_safe.h:27
bdb_free
void bdb_free(void *mem)
Definition: lib_safe.c:327
s_lckpwrite
int s_lckpwrite(int fd, const void *buf, size_t len, off_t off)
Definition: lib_safe.c:198
LINFO
#define LINFO(f...)
Definition: lib_log.h:69
x_strdup
char * x_strdup(const char *s, char *file, unsigned int line)
Definition: lib_safe.c:447
s_zmalloc
#define s_zmalloc(size)
Definition: lib_safe.h:24
estamp
void estamp()
Definition: lib_safe.c:215
lib_net.h
s_realloc
void * s_realloc(void *ptr, size_t size)
Definition: lib_safe.c:497
x_zmalloc
void * x_zmalloc(size_t size, char *file, unsigned int line)
Definition: lib_safe.c:390
s_pwrite
int s_pwrite(int fd, const void *buf, size_t len, off_t off)
Definition: lib_safe.c:176
LDEBUG
#define LDEBUG(f...)
Definition: lib_log.h:78
EXIT_SYSTEM
#define EXIT_SYSTEM
Definition: retcodes.h:22
s_malloc
#define s_malloc(size)
Definition: lib_safe.h:23
MEMINFO
Definition: lib_safe.h:36
mkpath
int mkpath(const char *s, mode_t mode)
Definition: lib_safe.c:681
x_malloc
void * x_malloc(size_t size, char *file, unsigned int line)
Definition: lib_safe.c:298
tstamp
void tstamp()
Definition: lib_safe.c:207
s_chdir
int s_chdir(const char *chpath)
Definition: lib_safe.c:461
s_fopen
FILE * s_fopen(char *path, char *mode)
Definition: lib_safe.c:471
exitFunc
void exitFunc()
Definition: lib_safe.c:223
s_pread
int s_pread(int fd, void *buf, size_t len, off_t off)
Definition: lib_safe.c:125
retcodes.h
x_basename
char * x_basename(char *path, char *file, unsigned int line)
Definition: lib_safe.c:654
ERRHANDLE
#define ERRHANDLE(f...)
Definition: lib_safe.h:21
s_strdup
#define s_strdup(size)
Definition: lib_safe.h:26
s_srtOpenDir
char ** s_srtOpenDir(char *processDir)
Definition: lib_safe.c:593
as_strarrcat
char * as_strarrcat(const char **strarr, ssize_t count)
Definition: lib_safe.c:545
bdb_malloc
void * bdb_malloc(size_t size)
Definition: lib_safe.c:313
bdb_realloc
void * bdb_realloc(void *ptr, size_t size)
Definition: lib_safe.c:513
pwrite_mutex
static pthread_mutex_t pwrite_mutex
Definition: lib_safe.c:63
s_open2
int s_open2(const char *pathname, int flags, mode_t mode)
Definition: lib_safe.c:489
s_read
int s_read(int fd, unsigned char *buf, int len)
Definition: lib_safe.c:103
MEMINFO::line
unsigned int line
Definition: lib_safe.h:40
MEMINFO::size
unsigned int size
Definition: lib_safe.h:38
leak_report
void leak_report()
s_free
#define s_free(mem_ref)
Definition: lib_safe.h:25
x_dirname
char * x_dirname(char *path, char *file, unsigned int line)
Definition: lib_safe.c:666
x_free
void x_free(void *mem, char *file, unsigned int line)
Definition: lib_safe.c:337