PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Proj4/pj_malloc.c

http://github.com/route-me/route-me
C | 28 lines | 17 code | 1 blank | 10 comment | 2 complexity | 0fc638d7bf493aa7bc7f0784c0197660 MD5 | raw file
 1/* allocate and deallocate memory */
 2#ifndef lint
 3static const char SCCSID[]="@(#)pj_malloc.c	4.3   93/06/12 GIE REL";
 4#endif
 5/* These routines are used so that applications can readily replace
 6** projection system memory allocation/deallocation call with custom
 7** application procedures.  */
 8#include "projects.h"
 9#include <errno.h>
10
11	void *
12pj_malloc(size_t size) {
13// Currently, pj_malloc is a hack to solve an errno problem.
14// The problem is described in more details at 
15// https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=86420. 
16// It seems, that pj_init and similar functions incorrectly 
17// (under debian/glibs-2.3.2) assume that pj_malloc resets 
18// errno after success. pj_malloc tries to mimic this.
19        int old_errno = errno;
20        void *res = malloc(size);       
21        if ( res && !old_errno )
22                errno = 0;        	 
23        return res;
24}
25	void
26pj_dalloc(void *ptr) {
27	free(ptr);
28}