Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (-1) | Shanky.com
Access Violation in a linked list

 
Post new topic   Reply to topic Printable version
 View previous topic  Help Please? Post :: Post Disallow Subchat, etc..  View next topic  
Author Message
Versetti
Novice


Gender:Gender:Male
Joined: Jan 05 2004
Posts: 54
Offline

PostPosted: Sat Feb 28, 2004 11:07 pm    Post subject: Access Violation in a linked list Reply to topic Reply with quote

I'm trying to make a addon for my biller and when the biller tries to add data in my linked lists it will say "Unhandled exception in SSGBiller.exe 0xC0000005: Access Violation."

Would anyone know how to fix this if you need to see anything else just ask and I'll show you some of that code you might need to help e out with this problem.
Back to top
View users profile Send private message Add User to Ignore List AIM Address MSN Messenger
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Sat Feb 28, 2004 11:54 pm    Post subject: Reply to topic Reply with quote

Lol show the code. Access violation is probably the most generic C++ error you can ever get.
_________________
This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sun Feb 29, 2004 1:28 am    Post subject: Reply to topic Reply with quote

Access violation is usually attempting to read/write NULL ptr, uninitialized ptr (ie garbage). As cyan said, post your code.
_________________
4,691 irradiated haggis!
Back to top
View users profile Send private message Add User to Ignore List
Versetti
Novice


Gender:Gender:Male
Joined: Jan 05 2004
Posts: 54
Offline

PostPosted: Sun Feb 29, 2004 11:06 am    Post subject: Reply to topic Reply with quote

Here is the liked lists I made for it:
Code: Show/Hide

class EntryBoardUser{
public:
   EntryBoardUser();
   ~EntryBoardUser();

   int UserID;         //Never Gets Replaced
   char Name[32];      //Replace1 -- 1
   char Email[100];   //Replace1 -- 2
   char Sig[256];      //Replace1 -- 3
   char title[32];      //Replace1 -- 4
   int posts;         //Replace2 -- 1
   int warnlevel;      //Replace2 -- 2
   int Level;         //Replace2 -- 3
   bool banned;      //Replace2 -- 4 -- (1 = False) (0 = True)
   bool limitread;      //Replace2 -- 5 -- (1 = False) (0 = True)
   ///put the stuff here
};

class BoardUser{
public:
   BoardUser();
   ~BoardUser();

   EntryBoardUser* item;
   BoardUser* next;
   BoardUser* prev;
   //the node is here
};

class ControlBoardUser{
public:
   ControlBoardUser();
   ~ControlBoardUser();

   BoardUser* head;
   BoardUser* tail;
   void clear();
   void remove(char *);
   bool Replace1(int ,char *,char *);
   bool Replace2(int ,char *,int );
};


then my append function is the first thing that gets the error:
Code: Show/Hide

void append(int ID,char *Name,char *Email,bool limit = false,int oplevel = 5,char *title2 = "Newbie"){
   ControlBoardUser *parse;
   if(parse->head && parse->tail){
      parse->head=parse->tail=new BoardUser;
      parse->head->item->UserID = ID;
      memcpy(parse->head->item->Name,Name,32);
      memcpy(parse->head->item->Email,Email,100);
      memcpy(parse->head->item->Sig,0,0);
      strncpy(parse->head->item->title,title2,32);
      parse->head->item->posts = 0;
      parse->head->item->warnlevel = 0;
      parse->head->item->Level = oplevel;
      parse->head->item->banned = false;
      parse->head->item->limitread = limit;
      UserID2++;
   }
   if(parse->tail){
      BoardUser *parse2 = new BoardUser;
      parse2->item->UserID = ID;
      memcpy(parse2->item->Name,Name,32);
      memcpy(parse2->item->Email,Email,100);
      memcpy(parse2->item->Sig,0,0);
      strncpy(parse2->item->title,title2,32);
      parse2->item->posts = 0;
      parse2->item->warnlevel = 0;
      parse2->item->Level = oplevel;
      parse2->item->banned = false;
      parse2->item->limitread = limit;
      UserID2++;
      BoardUser *oldtail = parse->tail;
      parse->tail = parse2;
      parse2->prev = oldtail;
      oldtail->next = parse2;
   }

}


and the error is when I ever try to write to the linked list it will cause that error can you help?
Back to top
View users profile Send private message Add User to Ignore List AIM Address MSN Messenger
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sun Feb 29, 2004 12:21 pm    Post subject: Reply to topic Reply with quote

God I hate C++. Versetti, first of all, you are not showing enough code for me to figure out what you are trying to do. Secondly, the code that you do show is clearly very wrong in many ways. You can't use memcpy() here. Very bad. Very dangerous. Here's a generic function that shows proper linked list "add to tail" functionality...

Code: Show/Hide
void List::AddNewNode (blah blah)
{
Node *node;

if (node = new Node(blah blah))
   {
   if (node->prev = m_tail)
      m_tail = m_tail->next = node;
   else
      m_head = m_tail = node;
   }
}
Back to top
View users profile Send private message Add User to Ignore List
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> General Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 37 page(s) served in previous 5 minutes.

phpBB Created this page in 0.080709 seconds : 25 queries executed (61.7%): GZIP compression disabled