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

Diff of /lbbs/src/section_list.c

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

Revision 1.53 by sysadm, Tue Nov 4 14:58:56 2025 UTC Revision 1.54 by sysadm, Wed Nov 5 03:01:14 2025 UTC
# Line 45  union semun Line 45  union semun
45    
46  struct article_block_t  struct article_block_t
47  {  {
48          ARTICLE articles[ARTICLE_PER_BLOCK];          ARTICLE articles[BBS_article_count_per_block];
49          int article_count;          int article_count;
50          struct article_block_t *p_next_block;          struct article_block_t *p_next_block;
51  };  };
# Line 391  ARTICLE *article_block_find_by_index(int Line 391  ARTICLE *article_block_find_by_index(int
391                  return NULL;                  return NULL;
392          }          }
393    
394          if (index < 0 || index / ARTICLE_PER_BLOCK >= p_article_block_pool->block_count)          if (index < 0 || index / BBS_article_count_per_block >= p_article_block_pool->block_count)
395          {          {
396                  log_error("article_block_find_by_index(%d) is out of boundary of block [0, %d)\n", index, p_article_block_pool->block_count);                  log_error("article_block_find_by_index(%d) is out of boundary of block [0, %d)\n", index, p_article_block_pool->block_count);
397                  return NULL;                  return NULL;
398          }          }
399    
400          p_block = p_article_block_pool->p_block[index / ARTICLE_PER_BLOCK];          p_block = p_article_block_pool->p_block[index / BBS_article_count_per_block];
401    
402          if (index % ARTICLE_PER_BLOCK >= p_block->article_count)          if (index % BBS_article_count_per_block >= p_block->article_count)
403          {          {
404                  log_error("article_block_find_by_index(%d) is out of boundary of article [0, %d)\n", index, p_block->article_count);                  log_error("article_block_find_by_index(%d) is out of boundary of article [0, %d)\n", index, p_block->article_count);
405                  return NULL;                  return NULL;
406          }          }
407    
408          return (p_block->articles + (index % ARTICLE_PER_BLOCK));          return (p_block->articles + (index % BBS_article_count_per_block));
409  }  }
410    
411  extern int section_list_init(const char *filename)  extern int section_list_init(const char *filename)
# Line 767  int section_list_append_article(SECTION_ Line 767  int section_list_append_article(SECTION_
767          }          }
768    
769          if (p_article_block_pool->block_count == 0 ||          if (p_article_block_pool->block_count == 0 ||
770                  p_article_block_pool->p_block[p_article_block_pool->block_count - 1]->article_count >= ARTICLE_PER_BLOCK)                  p_article_block_pool->p_block[p_article_block_pool->block_count - 1]->article_count >= BBS_article_count_per_block)
771          {          {
772                  if ((p_block = pop_free_article_block()) == NULL)                  if ((p_block = pop_free_article_block()) == NULL)
773                  {                  {
# Line 777  int section_list_append_article(SECTION_ Line 777  int section_list_append_article(SECTION_
777    
778                  if (p_article_block_pool->block_count > 0)                  if (p_article_block_pool->block_count > 0)
779                  {                  {
780                          last_aid = p_article_block_pool->p_block[p_article_block_pool->block_count - 1]->articles[ARTICLE_PER_BLOCK - 1].aid;                          last_aid = p_article_block_pool->p_block[p_article_block_pool->block_count - 1]->articles[BBS_article_count_per_block - 1].aid;
781                  }                  }
782    
783                  p_article_block_pool->p_block[p_article_block_pool->block_count] = p_block;                  p_article_block_pool->p_block[p_article_block_pool->block_count] = p_block;
# Line 1300  int article_block_article_count(void) Line 1300  int article_block_article_count(void)
1300                  return -1;                  return -1;
1301          }          }
1302    
1303          ret = (p_article_block_pool->block_count - 1) * ARTICLE_PER_BLOCK +          ret = (p_article_block_pool->block_count - 1) * BBS_article_count_per_block +
1304                    p_article_block_pool->p_block[p_article_block_pool->block_count - 1]->article_count;                    p_article_block_pool->p_block[p_article_block_pool->block_count - 1]->article_count;
1305    
1306          return ret;          return ret;


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

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