Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - calloc

Pages: [1]
1
Development Deliberation /
« on: July 28, 2004, 07:40:32 pm »
It seems the bug only occurs from using a later version of MYSQL. I\'m using an alpha version 5.0.  That versions is releasing the MYSQL_FIELD data, when the next row is read, while apparently older versions of MYSQL don\'t.  

2
Development Deliberation /
« on: July 26, 2004, 07:48:17 pm »
Heres a quickfix.  I only just recently downloaded and compiled the source and haven\'t been able to do much testing.  I\'ve got as far as the character creation screen now, but apparently i need to download some missing graphic files.

Replace function with,

const char *psResultRow::operator[](const char *fieldname)
{
    CS_ASSERT(fieldname);
    CS_ASSERT(max); // trying to access when no fields returned in row! probably empty resultset.
    CS_ASSERT(MAX_TABLE_FIELDS > max); // if assert on startup, increase MAX_TABLE_FIELDS.
   
    int i;
    // If not stored, store or all field names.
    if( !fields )
    {
        for (i=0 ; i < max ; i++)
        {
            if(( fields = mysql_fetch_field (rs)) != NULL) {
                 strcpy(field_buffer, fields->name);
            } else CS_ASSERT(0);
        }
    }

    // search for specified field name in temp buffer.      
    for ( i=0 ; i < max ; i++ )
    {  
        if (!strcasecmp(field_buffer,fieldname))
        {  
            return rr;
        }
    }
    printf(\"Could not find field %s!. Exiting.\\n\",fieldname);
    CS_ASSERT(false);
    return \"\"; // Illegal name.
}

Add the lines below to dal.h

#define MAX_TABLE_FIELDS 100

char field_buffer[MAX_TABLE_FIELDS][60]; <-- put in public section

It would probably be to make field_buffer private and add some handlers or better yet replace arrays with something more efficient.

3
Development Deliberation /
« on: July 26, 2004, 05:50:48 pm »
There is a memory leak in that part of the code.  The psserver program exits with a segmentaion fault on startup on my sytem.  I managed to trace the memory leak to the same function as you did.

const char *psResultRow::operator[](const char *fieldname)  in  \"/src/server/database/mysql/dal.cpp\"

The problem is the memory that the fields* is pointing to is being released at some point. I wrote a quick fix that buffers the field names and now no more memory leak.  Unfortunately I don\'t have write access to the repository to upload the fix.


Pages: [1]