projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added a warning (always to stderr) when opening the log file fails
[yaz-moved-to-github.git]
/
src
/
nmem.c
diff --git
a/src/nmem.c
b/src/nmem.c
index
a16603d
..
1f8824f
100644
(file)
--- a/
src/nmem.c
+++ b/
src/nmem.c
@@
-1,8
+1,8
@@
/*
/*
- * Copyright (c) 1995-2004, Index Data.
+ * Copyright (c) 1995-2005, Index Data.
* See the file LICENSE for details.
*
* See the file LICENSE for details.
*
- * $Id: nmem.c,v 1.6 2004-11-18 15:18:13 heikki Exp $
+ * $Id: nmem.c,v 1.11 2005-01-05 10:23:42 adam Exp $
*/
/**
*/
/**
@@
-22,9
+22,10
@@
#include <assert.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
+#include <stddef.h>
#include <yaz/xmalloc.h>
#include <yaz/nmem.h>
#include <yaz/xmalloc.h>
#include <yaz/nmem.h>
-#include <yaz/ylog.h>
+#include <yaz/log.h>
#include <yaz/oid.h>
#ifdef WIN32
#include <yaz/oid.h>
#ifdef WIN32
@@
-41,6
+42,23
@@
#define NMEM_CHUNK (4*1024)
#define NMEM_CHUNK (4*1024)
+struct align {
+ char x;
+ union {
+ char c;
+ short s;
+ int i;
+ long l;
+#if HAVE_LONG_LONG
+ long long ll;
+#endif
+ float f;
+ double d;
+ } u;
+};
+
+#define NMEM_ALIGN (offsetof(struct align, u))
+
static int log_level=0;
static int log_level_initialized=0;
static int log_level=0;
static int log_level_initialized=0;
@@
-266,7
+284,7
@@
void *nmem_malloc(NMEM n, int size)
}
r = p->buf + p->top;
/* align size */
}
r = p->buf + p->top;
/* align size */
- p->top += (size + (sizeof(long) - 1)) & ~(sizeof(long) - 1);
+ p->top += (size + (NMEM_ALIGN - 1)) & ~(NMEM_ALIGN - 1);
n->total += size;
NMEM_LEAVE;
return r;
n->total += size;
NMEM_LEAVE;
return r;
@@
-472,15
+490,18
@@
void yaz_set_errno(int v)
void yaz_strerror(char *buf, int max)
{
void yaz_strerror(char *buf, int max)
{
+#ifdef WIN32
+ DWORD err;
+#endif
char *cp;
if (!log_level_initialized)
{
char *cp;
if (!log_level_initialized)
{
- log_level=yaz_log_module_level("nmem");
- log_level_initialized=1;
+ log_level = yaz_log_module_level("nmem");
+ log_level_initialized = 1;
}
#ifdef WIN32
}
#ifdef WIN32
- DWORD err = GetLastError();
+ err = GetLastError();
if (err)
{
FormatMessage(
if (err)
{
FormatMessage(