Menu

[r3049]: / trunk / toolkits / basemap / src / pj_malloc.c  Maximize  Restore  History

Download this file

29 lines (27 with data), 925 Bytes

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