long HashTab_Delete(SSDBufTag ssd_buf_tag, unsigned long hash_code)
{
    if (DEBUG)
        printf("[INFO] Delete buf_tag: %lu\n",ssd_buf_tag.offset);

    deleteCnt++;
    //printf("hashitem free times:%d\n",deleteCnt++);

    long del_id;
    SSDBufHashBucket *delitem;
    SSDBufHashBucket *nowbucket = GetSSDBufHashBucket(hash_code);

    while (nowbucket->next_item != NULL)
    {
        if (isSameTag(nowbucket->next_item->hash_key, ssd_buf_tag))
        {
            delitem = nowbucket->next_item;
            del_id = delitem->desp_serial_id;
            nowbucket->next_item = delitem->next_item;
            freebucket(delitem);
            return del_id;
        }
        nowbucket = nowbucket->next_item;
    }
    return -1;
}
Beispiel #2
0
static void freevpt (vpnode *node)

{   if (node->hoja) freebucket (node->u.hoja.bucket,node->u.hoja.size);
    else
    {   freevpt (node->u.interno.child1);
        free (node->u.interno.child1);
        freevpt (node->u.interno.child2);
        free (node->u.interno.child2);
    }
}
Beispiel #3
0
/*
 * main()函数读取版面的信息,然后生成每个版面的热点话题的id,
 * 根据话题的id找到该话题的标题,最后将生成结果写入文件中。
 */
int main (void)
{
	int i;
	int num;		//热点话题的实际数量(可能少于5个)
	char buf[40] = "boards";
	char curfile[80];
	FILE *fp, *hfp;
	char *tmp;

	chdir (BBSHOME);
	sprintf (curfile, ".BOARDS"); 
	if ((fp = fopen (curfile, "r")) == NULL)
		return 0;

	sprintf (curfile, "%s%s", TOPPATH, TOPFILE);
	if ((hfp = fopen (curfile, "w")) == NULL)
		return 0;

	fprintf (hfp, "<?php\nreturn array(\n");

	while (fread (bh, sizeof (struct boardheader), 1, fp) && bh->filename[0] != '\0')
	{
		sprintf (curfile, "%s/%s/.DIR", buf, bh->filename);

		num = gen_board_hot (curfile);		//生成热点话题的id
		freebucket ();

		if (num)
		{
			tmp = strtok (bh->title, " \t\n");
			tmp = strtok (NULL, " \t\n");
			for (i = 0; i < num; i++)
			{
				strcpy (top[i].boardename, bh->filename);
				strcpy (top[i].boardcname, tmp);
			}
		}

		sprintf (curfile, "%s/%s/.ORIGIN", buf, bh->filename);

		get_article_from_id (curfile, num);		//根据id找到相应的帖子
		write_hot (&hfp, num);					//将结果写入文件中
	}

	fprintf (hfp, ");\n?>\n");

	fclose (fp);
	fclose (hfp);

	return 0;
}