| 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 |
}; |
}; |
| 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) |
| 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 |
{ |
{ |
| 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; |
| 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; |