Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2702 in orxonox.OLD for orxonox/branches/chris/src/data_tank.cc


Ignore:
Timestamp:
Nov 2, 2004, 9:15:50 PM (20 years ago)
Author:
chris
Message:

orxonox/branches/chris: corrected a bug in DataTank

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/chris/src/data_tank.cc

    r2666 r2702  
    2424*/
    2525
    26 #include "datatank.h"
     26#include "data_tank.h"
    2727
    2828using namespace std;
     
    345345{
    346346        FILE* out;
    347         DataTree* act;
    348347       
    349348        out = fopen( filename, "w");
     
    403402        int type = 0;
    404403        char testfile[MAX_FILENAME_LENGHT];
    405        
     404
    406405        if( !postfix || !lfunc || !ffunc || !placeholderfile) return -1;
    407        
     406
    408407        sprintf( testfile, "blabla.%s", postfix);
    409408        if( (type = get_type( testfile)) != -1)
     
    420419        char** old_postfixes = postfixes;
    421420        void** old_placeholders = placeholders;
    422        
     421
    423422        // realloc
    424423        load_funcs = (void*(**)(char*)) malloc( sizeof( void*(*)(char*)) * (ntypes + 1));
    425424        free_funcs = (void(**)(void*)) malloc( sizeof( void(*)(void*)) * (ntypes + 1));
    426         postfixes = (char**) malloc( sizeof( char*) * POSTFIX_LENGHT * (ntypes + 1));
     425        postfixes = (char**) malloc( sizeof( char*) * (ntypes + 1));
    427426        placeholders = (void**) malloc( sizeof( void*) * (ntypes + 1));
    428427       
    429428        // copy
    430429        memcpy( load_funcs, old_load_funcs, sizeof( void*(*)(char*)) * ntypes);
    431         memcpy( free_funcs, old_free_funcs, sizeof( void*(*)(void*)) * ntypes);
    432         memcpy( postfixes, old_postfixes, sizeof( char*) * POSTFIX_LENGHT * ntypes);
     430        memcpy( free_funcs, old_free_funcs, sizeof( void(*)(void*)) * ntypes);
     431        memcpy( postfixes, old_postfixes, sizeof( char*) * ntypes);
    433432        memcpy( placeholders, old_placeholders, sizeof( void*) * ntypes);
     433       
     434        // free
     435        free( old_load_funcs);
     436        free( old_free_funcs);
     437        free( old_postfixes);
     438        free( old_placeholders);
    434439       
    435440        // add
     
    439444        load_funcs[type] = lfunc;
    440445        free_funcs[type] = ffunc;
    441         memset( postfixes[type], 0, 5);
    442         strncpy( postfixes[type], postfix, 5);
     446        postfixes[type] = (char*) malloc( sizeof( char) * POSTFIX_LENGHT);
     447        memset( postfixes[type], 0, POSTFIX_LENGHT);
     448        strncpy( postfixes[type], postfix, POSTFIX_LENGHT);
    443449        placeholders[type] = lfunc( placeholderfile);
    444450       
Note: See TracChangeset for help on using the changeset viewer.