/[LeafOK_CVS]/lbbs/src/memory_pool.c
ViewVC logotype

Diff of /lbbs/src/memory_pool.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.10 by sysadm, Fri Dec 19 06:16:27 2025 UTC Revision 1.12 by sysadm, Tue Jan 6 13:59:21 2026 UTC
# Line 3  Line 3 
3   * memory_pool   * memory_pool
4   *   - memory pool   *   - memory pool
5   *   *
6   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>   * Copyright (C) 2004-2026  Leaflet <leaflet@leafok.com>
7   */   */
8    
9  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
# Line 80  inline static void *memory_pool_add_chun Line 80  inline static void *memory_pool_add_chun
80          void *p_chunk;          void *p_chunk;
81          void *p_node;          void *p_node;
82          size_t i;          size_t i;
83            size_t chunk_size;
84    
85          if (p_pool->chunk_count >= p_pool->chunk_count_limit)          if (p_pool->chunk_count >= p_pool->chunk_count_limit)
86          {          {
87                  log_error("Chunk count limit %d reached", p_pool->chunk_count);                  log_error("Chunk count limit %d reached", p_pool->chunk_count);
88                  return NULL;                  return NULL;
89          }          }
90          p_chunk = malloc(p_pool->node_size * p_pool->node_count_per_chunk);  
91            chunk_size = p_pool->node_size * p_pool->node_count_per_chunk;
92            p_chunk = malloc(chunk_size);
93          if (p_chunk == NULL)          if (p_chunk == NULL)
94          {          {
95                  log_error("malloc(%d * %d) error: OOM", p_pool->node_size, p_pool->node_count_per_chunk);                  log_error("malloc(%zu) error: OOM", chunk_size);
96                  return NULL;                  return NULL;
97          }          }
98    
# Line 180  int memory_pool_check_node(MEMORY_POOL * Line 183  int memory_pool_check_node(MEMORY_POOL *
183                          else                          else
184                          {                          {
185                                  log_error("Address of node (%p) is not aligned with border of chunk %d [%p, %p)",                                  log_error("Address of node (%p) is not aligned with border of chunk %d [%p, %p)",
186                                                    i, p_node >= p_pool->p_chunks[i], (char *)(p_pool->p_chunks[i]) + chunk_size);                                                    p_node, i, p_pool->p_chunks[i], (char *)(p_pool->p_chunks[i]) + chunk_size);
187                                  return -3;                                  return -3;
188                          }                          }
189                  }                  }


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1