| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Linked List - Why won`t compile ?! |
Hello there !
I would like to use my linked list class, which I used previously with my
DOS and Windows programs. The class compiled great then. Now (GNU C++) for
OS/2, it won't anymore ?!{at}#$
Here are the files :
===[DBLLIST.HPP]===
#if !defined( DBLLIST )
#define DBLLIST
#endif
typedef struct de_type
{
struct de_type *prev;
struct de_type *next;
void *de_body;
unsigned de_size;
} dblentry;
class dbllist
{
dblentry *anchor;
dblentry *hold;
dblentry *create(void *,unsigned);
public:
dblentry *base;
dbllist();
~dbllist();
void kill();
void init();
void *gohead();
void *current();
void *gotail();
void *gonext();
void *goprev();
void *append(void *,unsigned);
void *insert(void *,unsigned);
};
===================
===[DBLLIST.CC]===
#include "/prj/include/dbllist.hpp"
dblentry *dbllist::create(void * data, unsigned bytes)
{
if ( NULL == ( hold = (dblentry *)malloc(sizeof(dblentry))))
return NULL;
if ( NULL == ( hold->de_body = malloc(bytes)))
{
free(hold);
return NULL;
}
memmove(hold->de_body,data,bytes);
hold->prev = hold->next = NULL;
hold->de_size = bytes;
return hold;
}
dbllist::dbllist()
{
anchor = base = hold = NULL;
}
dbllist::~dbllist()
{
kill();
}
void dbllist::init()
{
anchor = base = hold = NULL;
}
void dbllist::kill()
{
base = anchor;
while( base )
{
hold = base->next;
free( base->de_body );
free( base );
base = hold;
}
anchor = base = hold = NULL;
}
void *dbllist::gohead()
{
base = anchor;
if ( base ) return base->de_body;
else return NULL;
}
void *dbllist::current()
{
if ( base ) return base->de_body;
else return NULL;
}
void *dbllist::gotail()
{
if ( base )
{
while( base->next ) base = base->next;
return base->de_body;
}
else return NULL;
}
void *dbllist::gonext()
{
if ( base )
{
if ( base->next )
{
base = base->next;
return base->de_body;
}
else return NULL;
}
else return NULL;
}
void *dbllist::goprev()
{
if ( base )
{
if ( base->prev )
{
base = base->prev;
return base->de_body;
}
else return NULL;
}
else return NULL;
}
void *dbllist::append(void *data, unsigned bytes)
{
dblentry *temp;
if ( NULL == (temp = create(data,bytes))) return NULL;
gotail();
if ( !base )
{
anchor = base = temp;
}
else
{
base->next = temp;
temp->prev = base;
base = temp;
}
return base->de_body;
}
void *dbllist::insert(void *data, unsigned bytes)
{
dblentry *temp;
gohead();
if ( !base ) return ( append( data,bytes) );
if (NULL == (temp=create(data,bytes))) return NULL;
while (base->next && memcmp(data,base->de_body,bytes)>0)
base = base->next;
if ( !base->next && memcmp(data,base->de_body,bytes)>0)
{
base->next = temp;
temp->prev = base;
base = temp;
}
else
{
hold = base->prev;
temp->prev = hold;
temp->next = base;
base->prev = temp;
if ( !hold ) anchor = temp;
else hold->next = temp;
base = temp;
}
return base->de_body;
}
==================
*** Continued next message ***
--- timEd/2-B10
* Origin: I'm too sexy for this origin (2:291/1301)SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407 SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809 @PATH: 291/1301 1928 292/850 293/2602 270/101 105/103 42 712/515 711/808 809 @PATH: 711/934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.