www.pudn.com > virtualListview_demo.zip > datastruct.cpp
#include "stdafx.h"
#include "datastruct.h"
//create a new DATA struct and init with some simple data. Add to the front of list,
//and return the new list
DATA *CreateNode(DATA *list, int id)
{
DATA *newnode = NULL;
newnode = (DATA*)malloc(sizeof(DATA));
if(newnode)
{
ZeroMemory(newnode, sizeof(DATA));
sprintf(newnode->field1, "Field1 %d", id);
sprintf(newnode->field2, "Field2 %d", id);
sprintf(newnode->field3, "Field3 %d", id);
newnode->next = list;
}
else
newnode = list;
return newnode;
}
void FreeAll(DATA *list)
{
DATA *tempptr = list;
while(list)
{
list = list->next;
free(tempptr);
tempptr = list;
}
}