[Tux4kids-commits] r1040 - tuxmath/branches/lan/server

akash gangil gangil-guest at alioth.debian.org
Sat Jun 13 13:21:16 UTC 2009


Author: gangil-guest
Date: 2009-06-13 13:21:13 +0000 (Sat, 13 Jun 2009)
New Revision: 1040

Modified:
   tuxmath/branches/lan/server/mathcards.c
   tuxmath/branches/lan/server/server.c
Log:
allocated memory to ques.

Modified: tuxmath/branches/lan/server/mathcards.c
===================================================================
--- tuxmath/branches/lan/server/mathcards.c	2009-06-12 23:01:12 UTC (rev 1039)
+++ tuxmath/branches/lan/server/mathcards.c	2009-06-13 13:21:13 UTC (rev 1040)
@@ -1447,7 +1447,7 @@
     return;
   mcdprintf("Copying '%s' to '%s', ", src->formula_string,dest->formula_string);
   mcdprintf("copying '%s' to '%s'\n", src->answer_string, dest->answer_string);
-  strncpy(dest->formula_string, src->formula_string, max_formula_size);
+  strncpy(dest->formula_string, src->formula_string, 1);
   strncpy(dest->answer_string, src->answer_string, max_answer_size);
   mcdprintf("Card is: '%s', '%s'\n", dest->formula_string, dest->answer_string);
   dest->answer = src->answer;

Modified: tuxmath/branches/lan/server/server.c
===================================================================
--- tuxmath/branches/lan/server/server.c	2009-06-12 23:01:12 UTC (rev 1039)
+++ tuxmath/branches/lan/server/server.c	2009-06-13 13:21:13 UTC (rev 1040)
@@ -28,7 +28,7 @@
 TCPsocket sd, csd; /* Socket descriptor, Client socket descriptor */
 
 int main(int argc, char **argv)
-{
+{ 
        
         IPaddress ip, *remoteIP;
         int quit, quit2;
@@ -36,10 +36,7 @@
         char func;
         MC_FlashCard* fc;
 
-        fc = malloc(sizeof(MC_FlashCard));
-        fc->answer_string="";
-        fc->formula_string="";
- 
+        
         if (SDLNet_Init() < 0)
         {
                 fprintf(stderr, "SDLNet_Init: %s\n", SDLNet_GetError());
@@ -47,7 +44,7 @@
         }
  
         /* Resolving the host using NULL make network interface to listen */
-        if (SDLNet_ResolveHost(&ip, NULL, 2950) < 0)
+        if (SDLNet_ResolveHost(&ip, NULL, 2940) < 0)
         {
                 fprintf(stderr, "SDLNet_ResolveHost: %s\n", SDLNet_GetError());
                 exit(EXIT_FAILURE);
@@ -117,6 +114,33 @@
                                                 case '2':
                                                   
                                                   {
+
+                                                   fc = (MC_FlashCard *)malloc(sizeof(MC_FlashCard));
+        
+                                                    if (fc == NULL) 
+            						{
+						             printf("Allocation of comets failed");
+						             return 0;
+					                }
+         
+					           else 
+					                {
+    						            *fc = MC_AllocateFlashcard();
+						            if (!MC_FlashCardGood(fc) ) 
+						             {
+						              //something's wrong
+						              printf("Allocation of flashcard failed\n");
+						              MC_FreeFlashcard(fc);
+						              return 0;
+						             }
+					                }
+					          fc->answer_string="";
+					          fc->formula_string="";
+ 
+
+                                                      
+
+
                                                     if (!MC_NextQuestion(fc))
                                                     { 
                                                       /* no more questions available - cannot create comet.  */




More information about the Tux4kids-commits mailing list