X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fnmem.c;h=62c02e2ce89f8aa0070dd89a6e78cb4f8116007e;hp=6fb23fd6cb8d76527a1df836b8f4006fc58f4bc4;hb=471c6dccdbb5c5a9c08b24c9abd6a1dcda29e79e;hpb=fb6d99a0c7e07d9cc4a315c447deaf6564a85505 diff --git a/src/nmem.c b/src/nmem.c index 6fb23fd..62c02e2 100644 --- a/src/nmem.c +++ b/src/nmem.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: nmem.c,v 1.19 2005-06-25 15:46:04 adam Exp $ + * $Id: nmem.c,v 1.22 2006-04-21 10:28:06 adam Exp $ */ /** @@ -109,17 +109,19 @@ struct nmem_mutex { YAZ_EXPORT void nmem_mutex_create(NMEM_MUTEX *p) { + NMEM_ENTER; if (!*p) { - *p = (NMEM_MUTEX) malloc (sizeof(**p)); + *p = (NMEM_MUTEX) malloc(sizeof(**p)); #ifdef WIN32 InitializeCriticalSection(&(*p)->m_handle); #elif YAZ_POSIX_THREADS - pthread_mutex_init (&(*p)->m_handle, 0); + pthread_mutex_init(&(*p)->m_handle, 0); #elif YAZ_GNU_THREADS - pth_mutex_init (&(*p)->m_handle); + pth_mutex_init(&(*p)->m_handle); #endif } + NMEM_LEAVE; if (!log_level_initialized) { log_level_initialized = 1; @@ -159,7 +161,7 @@ YAZ_EXPORT void nmem_mutex_destroy(NMEM_MUTEX *p) #ifdef WIN32 DeleteCriticalSection(&(*p)->m_handle); #endif - free (*p); + free(*p); *p = 0; } } @@ -232,12 +234,13 @@ static nmem_block *get_block(size_t size) } else { - int get = NMEM_CHUNK; + size_t get = NMEM_CHUNK; if (get < size) get = size; if(log_level) - yaz_log (log_level, "nmem get_block alloc new block size=%d", get); + yaz_log (log_level, "nmem get_block alloc new block size=%ld", + (long) get); r = (nmem_block *)xmalloc(sizeof(*r)); r->buf = (char *)xmalloc(r->size = get);