2 Star 3 Fork 5

杰杰/Linux_Gateway-ioT

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
dota_cache_test.c 2.57 KB
一键复制 编辑 原始数据 按行查看 历史
HoweiXue 提交于 2016-05-24 19:56 +08:00 . Linux物联网网关(多线程实现)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "dota_cache.h"
struct charpack
{
char a;
char b;
char c;
};
struct intpack
{
int a;
int b;
int c;
};
int main ()
{
dota_cache_list hc = CreateEmptyCacheList ();
dota_cache_list tc = hc;
dota_cache_list hi = CreateEmptyCacheList ();
dota_cache_list ti = hi;
dota_cache_list temp;
struct charpack *pc ;
pc = (struct charpack *) malloc (sizeof (struct charpack));
pc->a = 'a';
pc->b = 'b';
pc->c = 'c';
struct intpack *pi;
pi = (struct intpack *) malloc (sizeof (struct intpack));
pi->a = 1;
pi->b = 2;
pi->c = 3;
InsertCacheNode (&tc, pc);
InsertCacheNode (&ti, pi);
pc = (struct charpack *) malloc (sizeof (struct charpack));
pc->a = 'd';
pc->b = 'e';
pc->c = 'f';
pi = (struct intpack *) malloc (sizeof (struct intpack));
pi->a = 4;
pi->b = 5;
pi->c = 6;
InsertCacheNode (&tc, pc);
InsertCacheNode (&ti, pi);
pc = (struct charpack *) malloc (sizeof (struct charpack));
pc->a = 'g';
pc->b = 'h';
pc->c = 'i';
pi = (struct intpack *) malloc (sizeof (struct intpack));
pi->a = 7;
pi->b = 8;
pi->c = 9;
InsertCacheNode (&tc, pc);
InsertCacheNode (&ti, pi);
printf ("Finished Insert\n");
temp = GetCacheNode (hc, &tc);
pc = (struct charpack *)temp->data;
printf ("%c, %c, %c\n", pc->a, pc->b, pc->c);
free (temp);
free (pc);
temp = GetCacheNode (hc, &tc);
pc = (struct charpack *)temp->data;
printf ("%c, %c, %c\n", pc->a, pc->b, pc->c);
free (temp);
free (pc);
temp = GetCacheNode (hc, &tc);
pc = (struct charpack *)temp->data;
printf ("%c, %c, %c\n", pc->a, pc->b, pc->c);
free (temp);
free (pc);
printf ("%p, %p, %p, %p\n", hi, ti, hi->next, ti->next);
temp = GetCacheNode (hi, &ti);
pi = (struct intpack *)temp->data;
printf ("%d, %d, %d\n", pi->a, pi->b, pi->c);
free (temp);
free (pi);
printf ("%p, %p, %p, %p\n", hi, ti, hi->next, ti->next);
temp = GetCacheNode (hi, &ti);
pi = (struct intpack *)temp->data;
printf ("%d, %d, %d\n", pi->a, pi->b, pi->c);
free (temp);
free (pi);
printf ("%p, %p, %p, %p\n", hi, ti, hi->next, ti->next);
temp = GetCacheNode (hi, &ti);
pi = (struct intpack *)temp->data;
printf ("%d, %d, %d\n", pi->a, pi->b, pi->c);
free (temp);
free (pi);
printf ("%p, %p, %p, %p\n", hi, ti, hi->next, ti->next);
pi = (struct intpack *) malloc (sizeof (struct intpack));
pi->a = 7;
pi->b = 8;
pi->c = 9;
InsertCacheNode (&ti, pi);
temp = GetCacheNode (hi, &ti);
pi = (struct intpack *)temp->data;
printf ("%d, %d, %d\n", pi->a, pi->b, pi->c);
free (temp);
free (pi);
printf ("%p, %p, %p, %p\n", hi, ti, hi->next, ti->next);
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jiejietop/Linux_Gateway-ioT.git
git@gitee.com:jiejietop/Linux_Gateway-ioT.git
jiejietop
Linux_Gateway-ioT
Linux_Gateway-ioT
master

搜索帮助