1 /* This code is part of the tng compression routines.
2  *
3  * Written by Daniel Spangberg
4  * Copyright (c) 2010, 2013, The GROMACS development team.
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the Revised BSD License.
9  */
10 
11 
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include "../../include/compression/tng_compress.h"
15 #include "../../include/compression/warnmalloc.h"
16 
Ptngc_warnmalloc_x(const size_t size,char * file,const int line)17 void DECLSPECDLLEXPORT *Ptngc_warnmalloc_x(const size_t size, char *file, const int line)
18 {
19   void *mem=malloc(size);
20   if (!mem)
21     {
22       fprintf(stderr,"TRAJNG ERROR: Could not allocate memory of size %lu at %s:%d\n",(unsigned long) size,file,line);
23       exit(EXIT_FAILURE);
24     }
25   return mem;
26 }
27 
Ptngc_warnrealloc_x(void * old,const size_t size,char * file,const int line)28 void DECLSPECDLLEXPORT *Ptngc_warnrealloc_x(void *old, const size_t size, char *file, const int line)
29 {
30   void *mem=realloc(old,size);
31   if (!mem)
32     {
33       fprintf(stderr,"TRAJNG ERROR: Could not allocate memory of size %lu at %s:%d\n",(unsigned long) size,file,line);
34       exit(EXIT_FAILURE);
35     }
36   return mem;
37 }
38