Changeset 5725

Show
Ignore:
Timestamp:
09/01/09 23:34:50 (3 years ago)
Author:
westram
Message:
  • removed useless macros:
    • GB_STRDUP (easily taken for GB_strdup)
    • GB_MEMCPY + GB_MEMSET + GB_FREE
    • GB_DELETE (replaced by freeset(xx,NULL))
  • added macros:
    • freeset (= free + assign)
    • freedup (= free + assign strdup'ed)
    • reassign (= free + assign + clear source var)
    • nulldup (=strdup accepting NULL; replacement for GB_strdup in C++ code)
  • use these macros where applicable
Location:
trunk
Files:
124 modified

Legend:

Unmodified
Added
Removed
  • trunk/ALIV3/a3_arbdb.cxx

    r5340 r5725  
    4747{ 
    4848   GB_exit(gb_main); 
    49  
    50    if (alignment) free(alignment); 
    51    alignment = 0; 
     49   freeset(alignment, 0); 
    5250} 
    5351 
  • trunk/ARBDB/adTest.c

    r5665 r5725  
    162162        case GB_DB:     { type_name = "GB_DB"; break; } 
    163163        default: { 
    164             static char *unknownType; 
    165             if (unknownType) free(unknownType); 
    166             unknownType = strdup(GBS_global_string("<unknown GB_TYPE=%i>", type)); 
    167             type_name   = unknownType; 
     164            static char *unknownType = 0; 
     165            freeset(unknownType, GBS_global_string_copy("<unknown GB_TYPE=%i>", type)); 
     166            type_name = unknownType; 
    168167            break; 
    169168        } 
     
    177176 
    178177    if (gb_father) { 
    179         static char *result; 
    180         char        *father_path = strdup(GB_get_db_path(gb_father)); 
    181         int          key_quark   = GB_KEY_QUARK(gbd); 
    182  
    183         if (result) { 
    184             free(result); 
    185             result = 0; 
    186         } 
    187  
    188         if (key_quark == 0) { // illegal 
    189             result = strdup(GBS_global_string("%s/<illegal quark=0>", father_path)); 
    190         } 
    191         else { 
    192             const char *key = GB_KEY(gbd); 
    193             result = strdup(GBS_global_string("%s/%s", father_path, key)); 
    194         } 
    195  
     178        char *father_path = strdup(GB_get_db_path(gb_father)); 
     179        int   key_quark   = GB_KEY_QUARK(gbd); 
     180 
     181        static char *result; // careful! used recursively 
     182        freeset(result, GBS_global_string_copy("%s/%s", father_path, key_quark ? GB_KEY(gbd) : "<illegal quark=0>")); 
     183        free(father_path); 
     184         
    196185        return result; 
    197186    } 
     
    336325        if (!lines_allowed || (*lines_allowed)>0) { 
    337326            printf("%*s Showing %s:\n", indent, "", whatto_show_later); 
    338             free(whatto_show_later); whatto_show_later = 0; 
     327            freeset(whatto_show_later, NULL);  
    339328            ++indent; 
    340329            GB_dump_internal(gb_show_later, lines_allowed); 
  • trunk/ARBDB/ad_config.c

    r5708 r5725  
    156156    GBT_config_parser *parser = GB_calloc(1, sizeof(*parser)); 
    157157 
    158     parser->config_string = GB_strdup(config_string); 
     158    parser->config_string = nulldup(config_string); 
    159159    parser->parse_pos     = 0; 
    160160 
     
    181181    int         pos = parser->parse_pos; 
    182182 
    183     free(item->name); 
    184     item->name = 0; 
     183    freeset(item->name, NULL); 
    185184    item->type = CI_END_OF_CONFIG; 
    186185 
  • trunk/ARBDB/ad_core.c

    r5708 r5725  
    243243 
    244244    Main = (struct gb_main_type *)gbm_get_mem(sizeof(struct gb_main_type),0); 
    245     if (path) Main->path = GB_STRDUP((char*)path); 
     245    if (path) Main->path = strdup((char*)path); 
    246246    Main->key_2_index_hash = GBS_create_hash(20000, GB_MIND_CASE); 
    247247    Main->compression_mask = -1;        /* allow all compressions */ 
     
    320320        case GB_STRING_SHRT:    type = GB_STRING; 
    321321        case GB_STRING: 
    322             if (!buffer) buffer = GB_STRDUP("1234"); 
     322            if (!buffer) buffer = strdup("1234"); 
    323323            p = buffer; 
    324324            while ( !(++(*p) )) { (*p)++;p++; if (!(*p)) break; } 
     
    505505    else 
    506506    { 
    507         GB_MEMCPY(&(ts->info), &(gbd->info), sizeof(gbd->info)); 
     507        memcpy(&(ts->info), &(gbd->info), sizeof(gbd->info)); 
    508508    } 
    509509 
     
    562562    else 
    563563    { 
    564         GB_MEMCPY(&(gbd->info), &(old->info),sizeof(old->info)); 
     564        memcpy(&(gbd->info), &(old->info),sizeof(old->info)); 
    565565    } 
    566566    gb_del_ref_and_extern_gb_transaction_save(old); 
     
    688688 
    689689    if (s){ 
    690         Main->keys[index].key = GB_STRDUP(s); 
     690        Main->keys[index].key = strdup(s); 
    691691        GBS_write_hash(Main->key_2_index_hash,s,index); 
    692692        if (Main->gb_key_data && create_gb_key){ 
     
    709709    for (index = 1; index < Main->keycnt; index++) { 
    710710        if (Main->keys[index].key){ 
    711             GBS_write_hash(Main->key_2_index_hash,Main->keys[index].key,0); 
    712             free(Main->keys[index].key); 
    713         } 
    714         Main->keys[index].key = 0; 
     711            GBS_write_hash(Main->key_2_index_hash, Main->keys[index].key, 0); 
     712            freeset(Main->keys[index].key, 0); 
     713        } 
    715714        Main->keys[index].nref = 0; 
    716715        Main->keys[index].next_free_key = 0; 
  • trunk/ARBDB/ad_load.c

    r5708 r5725  
    357357 
    358358        for (i=Main->last_updated; i<=lu; ++i) { 
    359             Main->dates[i] = GB_STRDUP("unknown date"); 
     359            Main->dates[i] = strdup("unknown date"); 
    360360            Main->last_updated = lu+1; 
    361361        } 
     
    11441144            *(p++) = c; 
    11451145        } 
    1146         *p=0; 
     1146        *p = 0; 
    11471147        if (p == buffer) break; 
    1148         if (Main->dates[j]) free(Main->dates[j]); 
    1149         Main->dates[j] = GB_STRDUP(buffer); 
     1148        freedup(Main->dates[j], buffer); 
    11501149    } 
    11511150    if (j>=255) { 
     
    13871386            if (strchr(opent,'R'))      ignoreMissingMaster = 1; 
    13881387        }else { 
    1389             char *base = GB_STRDUP(path); 
     1388            char *base = strdup(path); 
    13901389            char *ext = gb_findExtension(base); 
    13911390            { 
     
    14931492                            fprintf(stderr, "Using properties from %s\n", found_path); 
    14941493#endif /* DEBUG */ 
    1495                             free(path); 
    1496                             path  = found_path; 
     1494                            freeset(path, found_path); 
    14971495                            input = fopen(path, "rb"); 
    14981496                        } 
  • trunk/ARBDB/ad_prot.h

    r5711 r5725  
    205205int GB_testlocal P_((GBDATA *gbd)); 
    206206int GB_nsons P_((GBDATA *gbd)); 
    207 GB_ERROR GB_disable_quicksave P_((GBDATA *gbd, const char *reason)); 
     207void GB_disable_quicksave P_((GBDATA *gbd, const char *reason)); 
    208208GB_ERROR GB_resort_data_base P_((GBDATA *gb_main, GBDATA **new_order_list, long listsize)); 
    209209GB_ERROR GB_resort_system_folder_to_top P_((GBDATA *gb_main)); 
     
    393393/* admalloc.c */ 
    394394NOT4PERL void *GB_calloc P_((unsigned int nelem, unsigned int elsize)); 
     395char *GB_deprStrdup P_((const char *p)) __ATTR__DEPRECATED; 
    395396char *GB_strdup P_((const char *p)); 
    396397char *GB_strduplen P_((const char *p, unsigned len)); 
  • trunk/ARBDB/ad_save_load.c

    r5698 r5725  
    230230                if (i!=j)         /* otherwise the filename is correct */ 
    231231                { 
    232                     char *qdup = GB_STRDUP((char *)qsave); 
    233                     GB_CSTR qnew = gb_quicksaveName(path,j); 
     232                    char    *qdup = strdup(qsave); 
     233                    GB_CSTR  qnew = gb_quicksaveName(path,j); 
    234234 
    235235                    GB_rename_file(qdup,qnew); 
     
    873873    if (path && strchr(savetype, 'S') == 0) // 'S' dumps to stdout -> do not change path 
    874874    { 
    875         free(GB_MAIN(gb)->path); 
    876         GB_MAIN(gb)->path = GB_STRDUP(path); 
     875        freedup(GB_MAIN(gb)->path, path); 
    877876    } 
    878877    return GB_save_as(gb,path,savetype); 
     
    968967    if (gb_check_saveable(gb,path,savetype)) goto error; 
    969968 
    970     sec_path = GB_STRDUP(gb_overwriteName(path)); 
     969    sec_path = strdup(gb_overwriteName(path)); 
    971970 
    972971    if (strchr(savetype,'S')) { 
     
    10011000        fprintf(out,"/*ARBDB ASCII*/\n"); 
    10021001        erg = gb_write_rek(out,(GBCONTAINER *)gb,0,1); 
    1003         if (erg==0) 
    1004         { 
    1005             if (Main->qs.quick_save_disabled) free(Main->qs.quick_save_disabled); 
    1006             Main->qs.quick_save_disabled = strdup("Database saved in ASCII mode"); 
     1002        if (erg==0) { 
     1003            freedup(Main->qs.quick_save_disabled, "Database saved in ASCII mode"); 
    10071004            if (deleteQuickAllowed && gb_remove_all_but_main(Main,path)) goto error; 
    10081005        } 
     
    10281025        if (erg==0){ 
    10291026            if (!strchr(savetype,'f')){             /* allow quick saving unless saved in 'f' mode */ 
    1030                 if (Main->qs.quick_save_disabled) free(Main->qs.quick_save_disabled); 
    1031                 Main->qs.quick_save_disabled = 0; /* and allow quicksaving */ 
     1027                freeset(Main->qs.quick_save_disabled, NULL); /* delete reason, why quicksaving is disallowed */ 
    10321028            } 
    10331029            if (deleteQuickAllowed && gb_remove_quick_saved(Main,path)) goto error; 
     
    10721068        } 
    10731069    } 
    1074     free(sec_path);sec_path = 0; 
     1070    freeset(sec_path, NULL); 
    10751071    if (!strchr(savetype,'f')){ /* reset values unless out of order save */ 
    10761072        Main->last_saved_transaction = GB_read_clock(gb); 
     
    11441140        org_master = GB_follow_unix_link(Main->path); 
    11451141    }else{ 
    1146         org_master = GB_STRDUP(Main->path); 
     1142        org_master = strdup(Main->path); 
    11471143    } 
    11481144 
     
    11691165        full_path_of_source = gb_full_path(org_master); 
    11701166    }else{ 
    1171         full_path_of_source = GB_STRDUP(org_master); 
     1167        full_path_of_source = strdup(org_master); 
    11721168    } 
    11731169 
     
    11891185    } 
    11901186 
    1191     free(Main->path);       /* Symlink created -> rename allowed */ 
    1192     Main->path = GB_STRDUP(path); 
     1187    freedup(Main->path, path); /* Symlink created -> rename allowed */ 
    11931188 
    11941189    free(full_path_of_source); 
     
    12841279    const char *cwd; 
    12851280    char *res; 
    1286     if (path[0] == '/') return GB_STRDUP(path); 
     1281    if (path[0] == '/') return strdup(path); 
    12871282 
    12881283    cwd = GB_getcwd(); 
    12891284 
    1290     if (path[0] == 0) return GB_STRDUP(cwd); 
    1291     res = GB_STRDUP(GBS_global_string("%s/%s",cwd,path)); 
     1285    if (path[0] == 0) return strdup(cwd); 
     1286    res = GBS_global_string_copy("%s/%s",cwd,path); 
    12921287 
    12931288    return res; 
  • trunk/ARBDB/adcomm.c

    r5708 r5725  
    8484 
    8585void g_bcms_delete_Socinf(struct Socinf *THIS){ 
    86     if (THIS->username) free(THIS->username); 
    87     THIS->username = NULL; 
     86    freeset(THIS->username, NULL); 
    8887    THIS->next = 0; 
    89     free ((char *)THIS); 
     88    free(THIS); 
    9089} 
    9190 
     
    228227    if (hs->unix_name){ 
    229228        unlink(hs->unix_name); 
    230         free(hs->unix_name); 
    231         hs->unix_name = 0; 
     229        freeset(hs->unix_name, NULL); 
    232230    } 
    233231    close(hs->hso); 
    234     free((char *)Main->server_data); 
    235     Main->server_data = 0; 
     232    freeset(Main->server_data, NULL); 
     233 
    236234    return 0; 
    237235} 
     
    20152013        if (Main->users[i]) continue; 
    20162014        Main->users[i] = (struct gb_user_struct *) GB_calloc(sizeof(struct gb_user_struct),1); 
    2017         Main->users[i]->username = GB_STRDUP(user); 
     2015        Main->users[i]->username = strdup(user); 
    20182016        Main->users[i]->userid = i; 
    20192017        Main->users[i]->userbit = 1<<i; 
     
    20572055            if (Main->users[i]->nusers<=0) {/* kill user and his projects */ 
    20582056                free(Main->users[i]->username); 
    2059                 free((char *)Main->users[i]); 
    2060                 Main->users[i] = 0; 
     2057                freeset(Main->users[i], NULL); 
    20612058                fprintf(stdout,"The User %s has logged out\n",user); 
    20622059            } 
  • trunk/ARBDB/adhash.c

    r5690 r5725  
    437437        e       = (struct gbs_hash_entry *)gbm_get_mem(sizeof(struct gbs_hash_entry),GBM_HASH_INDEX); 
    438438        e->next = hs->entries[i]; 
    439         e->key  = copyKey ? GB_STRDUP(key) : key; 
     439        e->key  = copyKey ? strdup(key) : key; 
    440440        e->val  = val; 
    441441 
     
    473473        e       = (struct gbs_hash_entry *)gbm_get_mem(sizeof(struct gbs_hash_entry),GBM_HASH_INDEX); 
    474474        e->next = hs->entries[i]; 
    475         e->key  = (char *)GB_STRDUP(key); 
     475        e->key  = strdup(key); 
    476476        e->val  = 1; 
    477477         
     
    964964    /* check validity */ 
    965965    if (GB_GET_EXT_UPDATE_DATE(gbd) > cs->entries[i].clock) { 
    966         free( cs->entries[i].data) ; 
    967         cs->entries[i].data = 0; 
     966        freeset(cs->entries[i].data, NULL); 
    968967        cs->sum_data_size -= cs->entries[i].sizeof_data; 
    969968 
     
    1000999 
    10011000    /* free cache */ 
    1002     free( cs->entries[i].data) ; 
    1003     cs->entries[i].data = 0; 
     1001    freeset(cs->entries[i].data, NULL); 
    10041002    cs->sum_data_size -= cs->entries[i].sizeof_data; 
    10051003 
  • trunk/ARBDB/adindex.c

    r5625 r5725  
    367367                        gbd->flags2.extern_data = ue->d.ts->flags2.extern_data; 
    368368 
    369                         GB_MEMCPY(&gbd->info,&ue->d.ts->info,sizeof(gbd->info)); /* restore old information */ 
     369                        memcpy(&gbd->info,&ue->d.ts->info,sizeof(gbd->info)); /* restore old information */ 
    370370                        if (type >= GB_BITS) { 
    371371                            if (gbd->flags2.extern_data){ 
  • trunk/ARBDB/adlang1.c

    r5695 r5725  
    158158                GBS_strcat(str,"\n"); 
    159159            } 
    160             GB_DELETE(params); 
     160            freeset(params, NULL); 
    161161            res = GBS_strclose(str); 
    162162            err = GB_export_error("Unknown Parameter '%s' in command '%s'\n\tPARAMETERS:\n%s",argv[i].str,com,res); 
     
    175175static char *unEscapeString(const char *escapedString) { 
    176176    /* replaces all \x by x */ 
    177     char *result = GB_strdup(escapedString); 
     177    char *result = nulldup(escapedString); 
    178178    char *to     = result; 
    179179    char *from   = result; 
     
    17631763                    else { 
    17641764                        static char *parent = 0; 
    1765                         if (parent) free(parent); 
    1766                         parent              = get_taxonomy_string(tax_hash, parent_group, depth, error); 
    1767                         result              = parent; 
     1765                         
     1766                        freeset(parent, get_taxonomy_string(tax_hash, parent_group, depth, error)); 
     1767                        result = parent; 
    17681768                    } 
    17691769                } 
     
    17851785 
    17861786                    if (found) { 
     1787                        static char *full_group = 0; 
    17871788                        const char  *group_id   = (const char *)found; 
    1788                         static char *full_group = 0; 
    1789                         if (full_group) free(full_group); 
    1790                         full_group              = get_taxonomy_string(tax_hash, group_id, depth, error); 
    1791                         result                  = full_group; 
     1789 
     1790                        freeset(full_group, get_taxonomy_string(tax_hash, group_id, depth, error)); 
     1791                        result = full_group; 
    17921792                    } 
    17931793                    else { 
  • trunk/ARBDB/adlmacros.h

    r5708 r5725  
    33#define A_TO_I(c) if(c>'9') c-='A'-10; else c-='0'; 
    44 
    5 #   define GB_MEMALIGN(a,b)     memalign(a,b) 
    6  
    7 # define GB_MEMCPY(d,s,n)       memcpy(d,s,n) 
    8 # define GB_FREE(d)             free(d) 
    9 # define GB_STRDUP(s)           strdup(s) 
    10 # define GB_MEMSET(d,v,n)       memset(d,v,n) 
    11  
    12 #define GB_DELETE(a)        if (a) GB_FREE(a); a = 0 
     5 
     6// GB_STRDUP does no longer exist! 
     7// its only here to avoid my own versioning problems.. will disappear soon 
     8#if defined(DEVEL_RALF) 
     9#define GB_STRDUP(str) GB_deprStrdup(str) 
     10#else 
     11#define GB_STRDUP(str) strdup(str) 
     12#endif // DEVEL_RALF 
    1313 
    1414#if defined(DIGITAL) || defined(DARWIN) 
    15 # undef GB_MEMALIGN 
    1615# define GB_MEMALIGN(a,b) malloc(b) 
     16#else 
     17# define GB_MEMALIGN(a,b) memalign(a,b) 
    1718#endif 
    1819 
     
    2425# define GB_GET_SECURITY_READ(gb)   ((gb)->flags.security_read) 
    2526# define GB_GET_SECURITY_WRITE(gb)  ((gb)->flags.security_write) 
    26 # define GB_GET_SECURITY_DELETE(gb)     ((gb)->flags.security_delete) 
    27  
    28 # define GB_PUT_SECURITY_READ(gb,i)     do { (gb)->flags.security_read = (i); } while(0) 
    29 # define GB_PUT_SECURITY_WRITE(gb,i)    do { (gb)->flags.security_write = (i); } while(0) 
    30 # define GB_PUT_SECURITY_DELETE(gb,i)   do { (gb)->flags.security_delete = (i); } while(0) 
     27# define GB_GET_SECURITY_DELETE(gb) ((gb)->flags.security_delete) 
     28 
     29# define GB_PUT_SECURITY_READ(gb,i)   ((gb)->flags.security_read   = (i)) 
     30# define GB_PUT_SECURITY_WRITE(gb,i)  ((gb)->flags.security_write  = (i)) 
     31# define GB_PUT_SECURITY_DELETE(gb,i) ((gb)->flags.security_delete = (i)) 
    3132 
    3233/********************* RELATIVE ADRESSING **********/ 
     
    473474        gbd->info.istr.size = (unsigned char)siz; 
    474475        gbd->info.istr.memsize = (unsigned char)memsiz; 
    475         if (dat) GB_MEMCPY(&(gbd->info.istr.data[0]), (char *)dat, (size_t)(memsiz)); 
     476        if (dat) memcpy(&(gbd->info.istr.data[0]), (char *)dat, (size_t)(memsiz)); 
    476477    }else{ 
    477478        char *exData; 
     
    481482        exData = gbm_get_mem((size_t)memsiz,GB_GBM_INDEX(gbd)); 
    482483        SET_GB_EXTERN_DATA_DATA(gbd->info.ex,exData); 
    483         if (dat) GB_MEMCPY(exData, (char *)dat, (size_t)(memsiz)); 
     484        if (dat) memcpy(exData, (char *)dat, (size_t)(memsiz)); 
    484485    } 
    485486    GB_INDEX_CHECK_IN(gbd); 
     
    525526        (gbd)->info.istr.size = (unsigned char)(siz);                                       \ 
    526527        (gbd)->info.istr.memsize = (unsigned char)(memsiz);                                 \ 
    527         if (dat) GB_MEMCPY(&((gbd)->info.istr.data[0]), (char *)(dat), (size_t)(memsiz));   \ 
     528        if (dat) memcpy(&((gbd)->info.istr.data[0]), (char *)(dat), (size_t)(memsiz));      \ 
    528529    }else{                                                                                  \ 
    529530        char *exData;                                                                       \ 
     
    533534        exData = gbm_get_mem((size_t)(memsiz),GB_GBM_INDEX(gbd));                           \ 
    534535        SET_GB_EXTERN_DATA_DATA((gbd)->info.ex,exData);                                     \ 
    535         if (dat) GB_MEMCPY(exData, (char *)(dat), (size_t)(memsiz));                        \ 
     536        if (dat) memcpy(exData, (char *)(dat), (size_t)(memsiz));                           \ 
    536537    }                                                                                       \ 
    537538    GB_INDEX_CHECK_IN(gbd);                                                                 \ 
     
    578579inline void STATIC_BUFFER(char*& strvar, int minlen) { 
    579580    ad_assert(minlen > 0);  
    580     if (strvar && (strlen(strvar) < (size_t)(minlen-1))) { free((void*)(strvar)); strvar=NULL; } 
     581    if (strvar && (strlen(strvar) < (size_t)(minlen-1))) { freeset(strvar, NULL); } 
    581582    if (!strvar) strvar=(char*)GB_calloc(minlen,1); 
    582583} 
     
    600601} while(0) 
    601602 
    602 #define STATIC_BUFFER(strvar,static_buffer_minlen)                                              \ 
    603 do {                                                                                            \ 
    604     ad_assert(static_buffer_minlen > 0);                                                        \ 
    605     size_t static_buffer_len = (static_buffer_minlen);                                          \ 
    606     if ((strvar) && (strlen(strvar) < (static_buffer_len-1))) { free(strvar); (strvar)=NULL; }  \ 
    607     if (!(strvar)) (strvar)=(char*)GB_calloc(static_buffer_len,1);                              \ 
    608 } while(0) 
    609  
    610 #endif 
     603#define STATIC_BUFFER(strvar,static_buffer_minlen)                      \ 
     604do {                                                                    \ 
     605    ad_assert(static_buffer_minlen > 0);                                \ 
     606    size_t static_buffer_len = (static_buffer_minlen);                  \ 
     607    if ((strvar) && (strlen(strvar) < (static_buffer_len-1))) {         \ 
     608        freeset(strvar, NULL);                                          \ 
     609    }                                                                   \ 
     610    if (!(strvar)) (strvar)=(char*)GB_calloc(static_buffer_len,1);      \ 
     611} while(0) 
     612 
     613#endif 
  • trunk/ARBDB/admalloc.c

    r5708 r5725  
    110110} 
    111111 
    112  
     112#if defined(DEVEL_RALF) 
     113char *GB_deprStrdup(const char *p) { 
     114    /* goes to header: __ATTR__DEPRECATED  */ 
     115    return strdup(p); 
     116} 
     117#endif /* DEVEL_RALF */ 
    113118 
    114119char *GB_strdup(const char *p) { 
    115     /* does strdup(), but working with NULL */ 
    116     if (p) return GB_STRDUP(p); 
    117     return NULL; 
     120    /* does strdup(), but working with NULL 
     121     * (Note: use nulldup() instead!)   
     122     */ 
     123    return p ? strdup(p) : NULL; 
    118124} 
    119125 
     
    155161    } 
    156162    else { /* end = 0 -> return copy of complete string */ 
    157         result = GB_strdup(start); 
     163        result = nulldup(start); 
    158164    } 
    159165 
     
    479485 
    480486    ggi->useditems[pos]++; 
    481     GB_MEMSET(erg,0,nsize); 
     487    memset(erg,0,nsize); 
    482488 
    483489    return erg; 
  • trunk/ARBDB/admap.c

    r5493 r5725  
    276276 
    277277        iecopy = (GB_REL_IFES *)malloc(iesize); 
    278         GB_MEMCPY(iecopy,ie,iesize); 
     278        memcpy(iecopy,ie,iesize); 
    279279 
    280280        /* write index entries an calc absolute offsets */ 
     
    294294        *offset += iesize; 
    295295 
    296         GB_FREE(iecopy); 
     296        free(iecopy); 
    297297    } 
    298298 
     
    374374                    headercopy = (struct gb_header_list_struct*) malloc(headermemsize); 
    375375                    ad_assert(sizeof(*headercopy)==ALIGN(sizeof(*headercopy))); 
    376                     GB_MEMSET(headercopy,0x0,headermemsize); 
     376                    memset(headercopy,0x0,headermemsize); 
    377377 
    378378                    for (item=0; item<nitems; item++) 
     
    404404                    headermemsize = ALIGN(valid * sizeof(*header)); 
    405405                    ftwrite_aligned(headercopy, headermemsize, out); 
    406                     GB_FREE(headercopy); 
     406                    free(headercopy); 
    407407 
    408408                }else{      /* Calc new indizes and size of header */ 
     
    609609 err2:  while (idx>=0) 
    610610 { 
    611      GB_FREE(gbk[idx].gbdoff); 
     611     free(gbk[idx].gbdoff); 
    612612     idx--; 
    613613 } 
    614     GB_FREE(gbk); 
     614    free(gbk); 
    615615 err1:  GB_memerr(); 
    616616    return NULL; 
     
    621621    int idx; 
    622622 
    623     for (idx=0; idx<Main->keycnt; idx++) GB_FREE(gbk[idx].gbdoff); 
    624     GB_FREE(gbk); 
     623    for (idx=0; idx<Main->keycnt; idx++) free(gbk[idx].gbdoff); 
     624    free(gbk); 
    625625} 
    626626 
     
    649649 
    650650    ad_assert(ADMAP_ID_LEN <= strlen(ADMAP_ID)); 
    651     GB_MEMSET(&mheader,0,sizeof(mheader)); 
     651    memset(&mheader,0,sizeof(mheader)); 
    652652    strcpy(mheader.mapfileID,ADMAP_ID); /* header */ 
    653653 
  • trunk/ARBDB/admath.c

    r5406 r5725  
    1919        double sum = 0; 
    2020        int i; 
    21         GB_DELETE(res); 
     21        freeset(res, NULL); 
    2222        max_n = n + 100; 
    2323        res = (double *)GB_calloc(sizeof(double),max_n); 
  • trunk/ARBDB/adoptimize.c

    r5625 r5725  
    177177    int idx; 
    178178    GBUSE(Main); 
    179     for (idx=0; idx<gbdByKey_cnt; idx++) GB_FREE(gbk[idx].gbds); 
    180     GB_FREE(gbk); 
     179    for (idx=0; idx<gbdByKey_cnt; idx++) free(gbk[idx].gbds); 
     180    free(gbk); 
    181181} 
    182182 
     
    24072407 
    24082408                data = gbm_get_mem(size, GBM_DICT_INDEX); 
    2409                 GB_MEMCPY(data, d, size); 
     2409                memcpy(data, d, size); 
    24102410                ad_assert(data[size-1] == 0); 
    24112411            } 
     
    25452545                        for (n=0; n<dict->words; n++) *nint++ = htonl(dict->resort[n]); 
    25462546 
    2547                         GB_MEMCPY(nint, dict->text, dict->textlen); 
     2547                        memcpy(nint, dict->text, dict->textlen); 
    25482548                    } 
    25492549 
  • trunk/ARBDB/adquery.c

    r5708 r5725  
    469469            return NULL; 
    470470        } 
    471         GB_MEMCPY(buffer,str,len); 
     471        memcpy(buffer,str,len); 
    472472    } 
    473473 
     
    10451045                            for (j = 0; j<args.cparam; ++j) { 
    10461046                                if (!paramlist) paramlist = strdup(args.vparam[j].str); 
    1047                                 else { 
    1048                                     char *conc = GBS_global_string_copy("%s,%s", paramlist, args.vparam[j].str); 
    1049                                     free(paramlist); 
    1050                                     paramlist  = conc; 
    1051                                 } 
     1047                                else freeset(paramlist, GBS_global_string_copy("%s,%s", paramlist, args.vparam[j].str)); 
    10521048                            } 
    10531049                            for (j = 0; j<args.cinput; ++j) { 
    10541050                                if (!inputstreams) inputstreams = strdup(args.vinput[j].str); 
    1055                                 else { 
    1056                                     char *conc   = GBS_global_string_copy("%s;%s", inputstreams, args.vinput[j].str); 
    1057                                     free(inputstreams); 
    1058                                     inputstreams = conc; 
    1059                                 } 
     1051                                else freeset(inputstreams, GBS_global_string_copy("%s;%s", inputstreams, args.vinput[j].str)); 
    10601052                            } 
    10611053 
  • trunk/ARBDB/adseqcompr.c

    r5390 r5725  
    251251 
    252252#if defined(SAVE_COMPRESSION_TREE_TO_DB) 
    253     if (node->name) { 
    254         free(node->name); 
    255         node->name = 0; 
    256     } 
    257  
     253    freeset(node->name, 0); 
    258254    if (node->index2 != -1) { 
    259255        node->name = GBS_global_string_copy("master_%03i", node->index2); 
     
    548544                            sumorg += seq_len; 
    549545 
    550                             GB_FREE(seqm); 
    551                             GB_FREE(seq); 
     546                            free(seqm); 
     547                            free(seq); 
    552548                        } 
    553549 
     
    588584                                GB_write_string(gbd,""); 
    589585                                GB_write_string(gbd,data); 
    590                                 GB_FREE(data); 
     586                                free(data); 
    591587 
    592588                                sumold += size; 
     
    671667 
    672668                    if (!error) { 
    673                         char *sizeOrg = GB_STRDUP(GBS_readable_size(sumorg)); 
    674                         char *sizeOld = GB_STRDUP(GBS_readable_size(sumold)); 
    675                         char *sizeNew = GB_STRDUP(GBS_readable_size(sumnew)); 
     669                        char *sizeOrg = strdup(GBS_readable_size(sumorg)); 
     670                        char *sizeOld = strdup(GBS_readable_size(sumold)); 
     671                        char *sizeNew = strdup(GBS_readable_size(sumnew)); 
    676672 
    677673                        GB_warning("Alignment '%s':\n" 
     
    698694 
    699695                // free data 
    700                 GB_FREE(seqs); 
    701                 for (si=0;si<mastercount;si++)GB_FREE(masters[si]); 
    702                 GB_FREE(masters); 
     696                free(seqs); 
     697                for (si=0;si<mastercount;si++) free(masters[si]); 
     698                free(masters); 
    703699            } 
    704700        } 
  • trunk/ARBDB/adsocket.c

    r5711 r5725  
    133133    } 
    134134    if (size>holding) size = holding; 
    135     GB_MEMCPY(ptr,gb_local->write_ptr,(int)size); 
     135    memcpy(ptr,gb_local->write_ptr,(int)size); 
    136136    gb_local->write_ptr += size; 
    137137    gb_local->write_free+= size; 
     
    203203 
    204204    while  (size >= gb_local->write_free){ 
    205         GB_MEMCPY(gb_local->write_ptr, ptr, (int)gb_local->write_free); 
     205        memcpy(gb_local->write_ptr, ptr, (int)gb_local->write_free); 
    206206        gb_local->write_ptr += gb_local->write_free; 
    207207        size -= gb_local->write_free; 
     
    211211        if (gbcm_write_flush(socket)) return GBCM_SERVER_FAULT; 
    212212    } 
    213     GB_MEMCPY(gb_local->write_ptr, ptr, (int)size); 
     213    memcpy(gb_local->write_ptr, ptr, (int)size); 
    214214    gb_local->write_ptr += size; 
    215215    gb_local->write_free -= size; 
     
    244244            return GB_export_error("OPEN_ARB_DB_CLIENT ERROR: missing ':' in %s",path); 
    245245        } 
    246         *m_name = GB_STRDUP(p+1); 
     246        *m_name = strdup(p+1); 
    247247        *id = -1; 
    248248        return 0; 
     
    455455{ 
    456456    char *key; 
    457     long  strlen = gbcm_read_long(socket); 
    458  
    459     if (strlen) { 
    460         if (strlen>0) { 
    461             key = (char *)GB_calloc(sizeof(char), (size_t)strlen+1); 
    462             gbcm_read(socket, key, strlen); 
     457    long  len = gbcm_read_long(socket); 
     458 
     459    if (len) { 
     460        if (len>0) { 
     461            key = (char *)GB_calloc(sizeof(char), (size_t)len+1); 
     462            gbcm_read(socket, key, len); 
    463463        } 
    464464        else { 
     
    467467    } 
    468468    else { 
    469         key = GB_strdup(""); 
     469        key = strdup(""); 
    470470    } 
    471471 
     
    610610    if (len<0) return 0; 
    611611    buffer[len] = 0; 
    612     if (path[0] == '/') return GB_STRDUP(buffer); 
    613  
    614     path2 = GB_STRDUP(path); 
     612    if (path[0] == '/') return strdup(buffer); 
     613 
     614    path2 = strdup(path); 
    615615    pos = strrchr(path2,'/'); 
    616616    if (!pos){ 
    617617        free(path2); 
    618         return GB_STRDUP(buffer); 
     618        return strdup(buffer); 
    619619    } 
    620620    *pos = 0; 
    621     res =  GB_STRDUP(GBS_global_string("%s/%s",path2,buffer)); 
     621    res  = GBS_global_string_copy("%s/%s",path2,buffer); 
    622622    free(path2); 
    623623    return res; 
     
    11721172        } while((step_size=step_size/2) > sizeof(void*)); 
    11731173 
    1174         while(head) { 
    1175             void *tmp; 
    1176             tmp=*(void**)head; 
    1177             free(head); 
    1178             head=tmp; 
    1179         } 
    1180  
     1174        while (head) freeset(head, *(void**)head); 
    11811175        max_malloc /= 1024; 
    11821176    } 
  • trunk/ARBDB/adstring.c

    r5708 r5725  
    3737GB_ERROR gb_scan_directory(char *basename, struct gb_scandir *sd) { /* goes to header: __ATTR__USERESULT */ 
    3838    /* look for quick saves (basename = yyy/xxx no arb ending !!!!) */ 
    39     char *path = GB_STRDUP(basename); 
     39    char *path = strdup(basename); 
    4040    const char *fulldir = "."; 
    4141    char *file = strrchr(path,'/'); 
     
    136136                    if (filename_only) strcpy(buffer, dp->d_name); 
    137137                    if (result) { 
    138                         char *neu = GB_strdup(GBS_global_string("%s*%s", result, buffer)); 
    139                         free(result); 
    140                         result    = neu; 
     138                        freeset(result, GBS_global_string_copy("%s*%s", result, buffer)); 
    141139                    } 
    142140                    else { 
    143                         result = GB_strdup(buffer); 
     141                        result = strdup(buffer); 
    144142                    } 
    145143                } 
     
    170168                    if ((GB_ULONG)st.st_mtime > newest){ 
    171169                        newest = st.st_mtime; 
    172                         if (result) free(result); 
    173                         result = GB_STRDUP(&dp->d_name[0]); 
     170                        freedup(result, dp->d_name); 
    174171                    } 
    175172                } 
     
    239236    vsprintf(p,templat,parg); 
    240237 
    241     if (GB_error_buffer) free(GB_error_buffer); 
    242     GB_error_buffer = GB_STRDUP(buffer); 
     238    freedup(GB_error_buffer, buffer); 
    243239    return GB_error_buffer; 
    244240} 
     
    274270        } 
    275271 
    276         if (GB_error_buffer) free(GB_error_buffer); 
    277         GB_error_buffer = GB_STRDUP(buffer); 
     272        freedup(GB_error_buffer, buffer); 
    278273    } 
    279274    return GB_error_buffer; 
     
    299294 
    300295void GB_clear_error() {         /* clears the error buffer */ 
    301     free(GB_error_buffer); 
    302     GB_error_buffer = 0; 
     296    freeset(GB_error_buffer, 0); 
    303297} 
    304298 
     
    500494    for (;i<GB_KEY_LEN_MIN;i++) buf[i] = '_'; 
    501495    buf[i] = 0; 
    502     return GB_STRDUP(buf); 
     496    return strdup(buf); 
    503497} 
    504498 
     
    543537    char *dest; 
    544538    dest = (char *)malloc((size_t)len); 
    545     GB_MEMCPY(dest,source,(int)len); 
     539    memcpy(dest,source,(int)len); 
    546540    return dest; 
    547541} 
     
    863857    int   ch; 
    864858 
    865     s = d = result = GB_STRDUP(com); 
     859    s = d = result = strdup(com); 
    866860    while ( (ch = *(s++)) ){ 
    867861        switch (ch) { 
     
    899893    int   ch; 
    900894 
    901     s = d = result = GB_STRDUP(com); 
     895    s = d = result = strdup(com); 
    902896    while ( (ch = *(s++)) ){ 
    903897        switch (ch) { 
     
    11211115 
    11221116    gbs_strensure_mem(strstr,len); 
    1123     GB_MEMCPY(strstr->GBS_strcat_data+strstr->GBS_strcat_pos,ptr,(int)len); 
     1117    memcpy(strstr->GBS_strcat_data+strstr->GBS_strcat_pos,ptr,(int)len); 
    11241118    strstr->GBS_strcat_pos += len; 
    11251119    strstr->GBS_strcat_data[strstr->GBS_strcat_pos]  = 0; 
     
    11311125     */ 
    11321126    gbs_strensure_mem(strstr,len+2); 
    1133     GB_MEMCPY(strstr->GBS_strcat_data+strstr->GBS_strcat_pos,ptr,(int)len); 
     1127    memcpy(strstr->GBS_strcat_data+strstr->GBS_strcat_pos,ptr,(int)len); 
    11341128    strstr->GBS_strcat_pos += len; 
    11351129    strstr->GBS_strcat_data[strstr->GBS_strcat_pos] = 0; 
     
    12251219                        if (!gb_entry || gb_entry == gb_container) { 
    12261220                            GBS_reference_not_found = 1; 
    1227                             entry=GB_STRDUP(""); 
     1221                            entry = strdup(""); 
    12281222                        }else{ 
    12291223                            entry = GB_read_as_string(gb_entry); 
     
    13631357    char *command; 
    13641358 
    1365     if (!icommand || !icommand[0]) return GB_STRDUP(insource); 
     1359    if (!icommand || !icommand[0]) return strdup(insource); 
    13661360 
    13671361    command = gbs_compress_command(icommand); 
    1368     in = GB_STRDUP(insource);               /* copy insource to allow to destroy it */ 
     1362    in = strdup(insource);               /* copy insource to allow to destroy it */ 
    13691363 
    13701364    for (doppelpunkt = command; doppelpunkt; doppelpunkt = nextdp) {    /* loop over command string */ 
     
    13951389        if ( (!*in) && doppelpunkt[0] == GBS_MWILD && doppelpunkt[1] == 0) {    /* empty string -> pars myself */ 
    13961390            /* * matches empty string !!!!  */ 
    1397             mwildcard[max_mwildcard++] = GB_STRDUP(""); 
    1398             gbs_build_replace_string(strstruct,bar,wildcard, max_wildcard, 
    1399                                      mwildcard, max_mwildcard,gb_container); 
     1391            mwildcard[max_mwildcard++] = strdup(""); 
     1392            gbs_build_replace_string(strstruct,bar,wildcard, max_wildcard, mwildcard, max_mwildcard,gb_container); 
    14001393            goto gbs_pars_unsuccessfull;    /* successfull search*/ 
    14011394        } 
     
    14121405                        start_of_wildcard = search; 
    14131406                        if ( !(c = *(search++) ) ) {    /* last character is a wildcard -> that was it */ 
    1414                             mwildcard[max_mwildcard++] = GB_STRDUP(source); 
     1407                            mwildcard[max_mwildcard++] = strdup(source); 
    14151408                            source += strlen(source); 
    14161409                            goto gbs_pars_successfull;      /* successfull search and end wildcard*/ 
     
    14741467            already_transferred = source; 
    14751468 
    1476             for (i = 0; i < max_mwildcard; i++){ 
    1477                 free (mwildcard[i]); 
    1478                 mwildcard[i] = 0; 
    1479             } 
    1480             max_wildcard = 0; max_mwildcard = 0; 
     1469            for (i = 0; i < max_mwildcard; i++) { 
     1470                freeset(mwildcard[i], 0); 
     1471            } 
     1472            max_wildcard  = 0; 
     1473            max_mwildcard = 0; 
    14811474 
    14821475            if (error) { 
     
    14921485 
    14931486        for (i = 0; i < max_mwildcard; i++){ 
    1494             free (mwildcard[i]); 
    1495             mwildcard[i] = 0; 
    1496         } 
    1497         max_wildcard = 0; max_mwildcard = 0; 
    1498  
    1499         free(in); 
    1500         in = GBS_strclose(strstruct); 
     1487            freeset(mwildcard[i], 0); 
     1488        } 
     1489        max_wildcard  = 0; 
     1490        max_mwildcard = 0; 
     1491 
     1492        freeset(in, GBS_strclose(strstruct)); 
    15011493    } 
    15021494    free(command); 
     
    16031595    gb_assert(dir);             // dir == NULL was allowed before 12/2008, forbidden now! 
    16041596 
    1605     char  *fulldir   = GB_strdup(GB_get_full_path(dir)); 
     1597    char  *fulldir   = nulldup(GB_get_full_path(dir)); 
    16061598    DIR   *dirstream = opendir(fulldir); 
    16071599    char **names     = NULL; 
     
    17871779 
    17881780char *GBS_extract_words( const char *source,const char *chars, float minlen, GB_BOOL sort_output ) { 
    1789     char  *s         = GB_STRDUP(source); 
     1781    char  *s         = strdup(source); 
    17901782    char **ps        = (char **)GB_calloc(sizeof(char *), (strlen(source)>>1) + 1); 
    17911783    void  *strstruct = GBS_stropen(1000); 
     
    20822074    char        *res; 
    20832075    int          rl      = strlen(regexprin)-2; 
     2076     
    20842077    if (regexprin[0] != '/' || regexprin[rl+1] != '/') { 
    20852078        GB_export_error("RegExprSyntax: '/searchterm/'"); 
     
    20872080        return 0; 
    20882081    } 
    2089     if (regexpr && !strncmp( regexpr, regexprin+1, rl)) 
    2090         goto already_compiled; 
    2091     if (regexpr) free(regexpr); 
    2092     regexpr = GB_STRDUP(regexprin+1); 
    2093     regexpr[rl] = 0; 
    2094  
    2095     regerrno = 0; 
    2096     res = compile(regexpr,&expbuf[0],&expbuf[8000],0); 
    2097     if (!res|| regerrno){ 
    2098         gbs_regerror(regerrno); 
    2099         return 0; 
    2100     } 
    2101  already_compiled: 
     2082 
     2083    if (!regexpr || strncmp(regexpr, regexprin+1, rl) != 0) { // first or new regexpr 
     2084        freedup(regexpr, regexprin+1); 
     2085        regexpr[rl] = 0; 
     2086        regerrno    = 0; 
     2087         
     2088        res = compile(regexpr,&expbuf[0],&expbuf[8000],0); 
     2089        if (!res|| regerrno){ 
     2090            gbs_regerror(regerrno); 
     2091            return 0; 
     2092        } 
     2093    } 
     2094 
    21022095    if (step((char *)in,expbuf)) return loc1; 
    21032096    return 0; 
     
    21182111    } 
    21192112    /* Copy regexpr and remove leading + trailing '/' */ 
    2120     regexpr = GB_STRDUP(regexprin+1); 
     2113    regexpr = strdup(regexprin+1); 
    21212114    regexpr[rl] = 0; 
    21222115 
     
    22002193 
    22012194    regerrno = 0; 
    2202     if (!old_reg_expr || strcmp (old_reg_expr ,regexpr)){ 
    2203         if (expbuf) free(expbuf); 
    2204         expbuf = compile(regexpr,0,0); 
    2205     } 
    2206     if (old_reg_expr) free(old_reg_expr); 
    2207     old_reg_expr = regexpr; 
    2208     regexpr = 0; 
     2195    if (!old_reg_expr || strcmp(old_reg_expr ,regexpr) != 0) { 
     2196        freeset(expbuf, compile(regexpr,0,0)); 
     2197    } 
     2198 
     2199    reassign(old_reg_expr, regexpr); 
    22092200 
    22102201    if (regerrno){ 
     
    24172408 
    24182409char *GBS_merge_tagged_strings(const char *s1, const char *tag1, const char *replace1, const char *s2, const char *tag2, const char *replace2){ 
    2419     char *str1 = GB_STRDUP(s1); 
    2420     char *str2 = GB_STRDUP(s2); 
     2410    char *str1 = strdup(s1); 
     2411    char *str2 = strdup(s2); 
    24212412    char *t1 = GBS_string_2_key(tag1); 
    24222413    char *t2 = GBS_string_2_key(tag2); 
     
    24422433 
    24432434char *GBS_string_eval_tagged_string(GBDATA *gb_main,const char *s, const char *dt, const char *tag, const char *srt, const char *aci, GBDATA *gbd){ 
    2444     char *str = GB_STRDUP(s); 
     2435    char *str = strdup(s); 
    24452436    char *default_tag = GBS_string_2_key(dt); 
    24462437    GB_HASH *hash = GBS_create_hash(16, GB_MIND_CASE); 
     
    25032494 notfound: 
    25042495    /* Nothing found */ 
    2505     free(buf); s = 0; 
     2496    free(buf); 
     2497    s = 0; 
    25062498 found: 
    25072499    free(tag); 
     
    25272519 
    25282520void GB_delete_set(GBDATA_SET *set){ 
    2529     GB_FREE(set->items); 
    2530     GB_FREE(set); 
     2521    free(set->items); 
     2522    free(set); 
    25312523} 
    25322524 
  • trunk/ARBDB/adsystem.c

    r5628 r5725  
    8181 
    8282void delete_gb_dictionary(GB_DICTIONARY *dict){ 
    83     GB_FREE(dict); 
     83    free(dict); 
    8484} 
    8585 
  • trunk/ARBDB/adtcp.c

    r5675 r5725  
    8181        int c; 
    8282        for (c = 0; ATD_content[c]; c++) free(ATD_content[c]); 
    83         free(ATD_content); 
    84         ATD_content = 0; 
     83        freeset(ATD_content, 0); 
    8584    } 
    8685} 
     
    130129                if (tok[0] == '#') break; /* EOL comment -> stop */ 
    131130                if (tokCount >= MAXTOKENS) { error = "Too many tokens"; break; } 
    132                 tokens[tokCount] = tokCount ? GBS_eval_env(tok) : GB_strdup(tok); 
     131                tokens[tokCount] = tokCount ? GBS_eval_env(tok) : strdup(tok); 
    133132                if (!tokens[tokCount]) { error = GB_get_error(); break; } 
    134133                tokCount++; 
     
    179178            } 
    180179 
    181             if (error) { 
    182                 error = GBS_global_string("%s (in line %i of '%s')", error, lineNumber, filename); 
    183             } 
    184  
    185             for (t = 0; t<tokCount; t++) { 
    186                 free(tokens[t]); 
    187                 tokens[t] = 0; 
    188             } 
     180            if (error) error = GBS_global_string("%s (in line %i of '%s')", error, lineNumber, filename); 
     181            for (t = 0; t<tokCount; t++) freeset(tokens[t], 0); 
    189182        } 
    190183 
     
    319312    if (strchr(env,':')){ 
    320313        static char *resBuf = 0; 
    321  
    322         free(resBuf); 
    323         resBuf = GB_STRDUP(env); 
     314        freedup(resBuf, env); 
    324315        result = resBuf; 
    325316    } 
     
    372363 
    373364        if (matchingEntriesSize != count) { 
    374             free(matchingEntries); 
    375             matchingEntries     = malloc((count+1)*sizeof(*matchingEntries)); 
     365            freeset(matchingEntries, malloc((count+1)*sizeof(*matchingEntries))); 
    376366            matchingEntriesSize = count; 
    377367        } 
     
    399389    static char *serverlog = 0; 
    400390    if (!serverlog) { 
    401         serverlog = GB_strdup(GB_path_in_ARBLIB("pts/ptserver.log", NULL)); 
     391        serverlog = nulldup(GB_path_in_ARBLIB("pts/ptserver.log", NULL)); 
    402392        gb_assert(serverlog); 
    403393    } 
     
    436426 
    437427        { 
    438             char *remote      = GB_strdup(ipPort); 
     428            char *remote      = strdup(ipPort); 
    439429            char *colon       = strchr(remote, ':'); 
    440430            if (colon) *colon = 0; /* hide port */ 
    441431 
    442432            if (strcmp(remote, "localhost") == 0) { /* hide localhost */ 
    443                 result = GB_strdup(nameOnly); 
     433                result = nulldup(nameOnly); 
    444434            } 
    445435            else { 
     
    478468                } 
    479469 
    480                 if (newResult) { free(result); result = newResult; } 
     470                if (newResult) freeset(result, newResult); 
    481471                free(serverDB); 
    482472            } 
  • trunk/ARBDB/adtools.c

    r5660 r5725  
    6060    for (counter = 1; !ali_other; ++counter) { 
    6161        ali_other = GBS_global_string_copy("ali_x%i", counter); 
    62         if (GBT_get_alignment(gbMain, ali_other) != 0) { 
    63             free(ali_other); 
    64             ali_other = 0; 
    65         } 
     62        if (GBT_get_alignment(gbMain, ali_other) != 0) freeset(ali_other, 0); // exists -> continue 
    6663    } 
    6764 
     
    575572 
    576573    if (pos>len){       /* no place to insert / delete */ 
    577         GB_MEMCPY(newval,source,(size_t)len); 
     574        memcpy(newval,source,(size_t)len); 
    578575        return NULL; 
    579576    } 
     
    584581 
    585582    if (nchar > 0)  {                   /* insert */ 
    586         GB_MEMCPY(newval,source,(size_t)pos); 
     583        memcpy(newval,source,(size_t)pos); 
    587584        memset(newval+pos,insert_what,(size_t)nchar); 
    588         GB_MEMCPY(newval+pos+nchar,source+pos,(size_t)(len-pos)); 
     585        memcpy(newval+pos+nchar,source+pos,(size_t)(len-pos)); 
    589586    }else{ 
    590         GB_MEMCPY(newval,source,(size_t)pos); 
    591         GB_MEMCPY(newval+pos,source+pos-nchar, (size_t)(len - pos + nchar)); 
     587        memcpy(newval,source,(size_t)pos); 
     588        memcpy(newval+pos,source+pos-nchar, (size_t)(len - pos + nchar)); 
    592589    } 
    593590    return newval; 
     
    862859        to delete the tree in Database 
    863860        just call GB_delete((GBDATA *)gb_tree); 
    864     */ 
     861     */ 
    865862{ 
    866     GB_ERROR error; 
    867     if (tree->name)  free(tree->name); 
    868     if (tree->remark_branch) free(tree->remark_branch); 
     863    free(tree->name); 
     864    free(tree->remark_branch); 
     865 
    869866    if (tree->is_leaf == 0) { 
     867        GB_ERROR error; 
     868         
    870869        gb_assert(tree->leftson); 
    871870        gb_assert(tree->rightson); 
     
    874873    } 
    875874    if (!tree->father || !tree->tree_is_one_piece_of_memory){ 
    876         free((char *)tree); 
     875        free(tree); 
    877876    } 
    878877    return 0; 
     
    14801479    TreeReader *reader = GB_calloc(1, sizeof(*reader)); 
    14811480 
    1482     reader->tree_file_name      = GB_strdup(file_name); 
     1481    reader->tree_file_name      = strdup(file_name); 
    14831482    reader->in                  = input; 
    14841483    reader->tree_comment        = GBS_stropen(2048); 
     
    16101609 
    16111610        assert(node->remark_branch == 0); 
    1612         node->remark_branch  = GB_strdup(GBS_global_string("%i%%", (int)bootstrap)); 
     1611        node->remark_branch  = GBS_global_string_copy("%i%%", (int)bootstrap); 
    16131612 
    16141613        if (end[0] != 0) {      // sth behind bootstrap value 
    16151614            if (end[0] == ':') ++end; // ARB format for nodes with bootstraps AND node name is 'bootstrap:nodename' 
    1616             node->name = GB_strdup(end); 
     1615            node->name = strdup(end); 
    16171616        } 
    16181617        free(name); 
     
    17221721                        } 
    17231722                         
    1724                         if (right) GB_FREE(right); 
     1723                        free(right); 
    17251724 
    17261725                        break; 
     
    17361735            } 
    17371736 
    1738             if (left) GB_FREE(left); 
     1737            free(left); 
    17391738        } 
    17401739    } 
     
    17761775        GB_BOOL     is_bootstrap = end[0] == '%' && end[1] == 0; 
    17771776 
    1778         free(tree->remark_branch); 
    1779         tree->remark_branch = 0; 
     1777        freeset(tree->remark_branch, 0); 
    17801778 
    17811779        if (is_bootstrap) { 
    17821780            bootstrap = bootstrap*bootstrap_scale+0.5; 
    1783             tree->remark_branch  = GB_strdup(GBS_global_string("%i%%", (int)bootstrap)); 
     1781            tree->remark_branch  = GBS_global_string_copy("%i%%", (int)bootstrap); 
    17841782        } 
    17851783    } 
     
    19131911        long *nnodes = GBT_read_int(gb_tree, "nnodes"); 
    19141912        if (nnodes && *nnodes>maxnodes) { 
    1915             free(largest); 
    1916             largest = GB_read_key(gb_tree); 
     1913            freeset(largest, GB_read_key(gb_tree)); 
    19171914            maxnodes = *nnodes; 
    19181915        } 
     
    30643061                    newname = &rns->data[0]; 
    30653062                } 
    3066                 free(tree->name); 
    3067                 tree->name = GB_STRDUP(newname); 
     3063                freedup(tree->name, newname); 
    30683064                rns->used_by = tree_index; 
    30693065            } 
     
    31403136                                struct gbt_renamed_struct *rns = (struct gbt_renamed_struct *)GBS_read_hash(gbtrst.renamed_hash, item->name); 
    31413137                                if (rns) { // species was renamed 
    3142                                     const char *newname = &rns->data[0]; 
    3143  
    3144                                     free(item->name); 
    3145                                     item->name = GB_STRDUP(newname); 
    3146                                     need_save  = 1; 
     3138                                    freedup(item->name, rns->data); 
     3139                                    need_save = 1; 
    31473140                                } 
    31483141                            } 
     
    31513144                        } 
    31523145 
    3153                         if (!error) { 
    3154                             free(*configStrPtr); 
    3155                             *configStrPtr = GBS_strclose(strstruct); 
    3156                         } 
     3146                        if (!error) freeset(*configStrPtr, GBS_strclose(strstruct)); 
    31573147 
    31583148                        GBT_free_config_item(item); 
     
    36923682            } 
    36933683        } 
    3694         if (error)  { 
    3695             free(result); 
    3696             result = 0; 
    3697         } 
     3684        if (error) freeset(result, 0); 
    36983685    } 
    36993686 
  • trunk/ARBDB/arbdb.c

    r5655 r5725  
    202202    old_buffer = gb_local->buffer; 
    203203    gb_local->buffer = (char *)GB_calloc((size_t)size,1); 
    204     GB_MEMCPY(gb_local->buffer,old_buffer, gb_local->bufsize); 
     204    memcpy(gb_local->buffer,old_buffer, gb_local->bufsize); 
    205205    gb_local->bufsize = size; 
    206206    free(old_buffer); 
     
    380380                if (da) { 
    381381                    ca = gb_alloc_cache_index(gbd,size); 
    382                     GB_MEMCPY(ca,da,size); 
     382                    memcpy(ca,da,size); 
    383383                } 
    384384            } 
     
    457457        da = gb_uncompress_bits(data,size,c_0,c_1); 
    458458        if (ca) { 
    459             GB_MEMCPY(ca,da,size+1); 
     459            memcpy(ca,da,size+1); 
    460460            return ca; 
    461461        }else{ 
     
    13811381                    p[0] = 0; 
    13821382 
    1383                     free(result); 
    1384                     result = neu_result; 
     1383                    freeset(result, neu_result); 
    13851384                    result_length += keylen+1; 
    13861385                } 
     
    14001399    } 
    14011400    else { 
    1402         result = GB_strdup(";"); 
     1401        result = strdup(";"); 
    14031402    } 
    14041403 
     
    20432042} 
    20442043 
    2045 GB_ERROR GB_disable_quicksave(GBDATA *gbd,const char *reason){ 
    2046     GB_MAIN_TYPE * Main = GB_MAIN(gbd); 
    2047     if (Main->qs.quick_save_disabled) free(Main->qs.quick_save_disabled); 
    2048     Main->qs.quick_save_disabled = strdup(reason); 
    2049     return 0; 
     2044void GB_disable_quicksave(GBDATA *gbd,const char *reason) { 
     2045    freedup(GB_MAIN(gbd)->qs.quick_save_disabled, reason); 
    20502046} 
    20512047/******************************************************************************************** 
     
    21242120    } 
    21252121    error = GB_resort_data_base(gb_main,new_order_list,len); 
    2126     GB_FREE(new_order_list); 
     2122    free(new_order_list); 
    21272123    return error; 
    21282124} 
  • trunk/ARBDB/arbdb_base.h

    r5708 r5725  
    2828typedef enum { GB_FALSE = 0 , GB_TRUE = 1 } GB_BOOL; 
    2929 
     30 
     31/* -------------------------------------------------------------------------------- 
     32 * The following function handle char*'s, which either own a heap copy or are NULL. 
     33 * 
     34 * freeset:  assigns a heap-copy to a variable (variable is automatically free'd) 
     35 * freedup:  similar to freeset, but strdup's the rhs-expression 
     36 * reassign: similar to freeset, but rhs must be variable and will be set to NULL 
     37 * nulldup:  like strdup, but pass-through NULL 
     38 * 
     39 * Note: freeset, freedup and reassign may safely use the changed variable in the rhs-expression! 
     40 * 
     41 * @@@ the complete section could go into a seperate header, 
     42 * but it makes no sense atm, cause we need GB_strdup anyway 
     43 * (using a macro would evaluate 'str' in nulldup twice - which is not ok) 
     44 */ 
     45 
     46#define freeset(var,str) do { typeof(var) freesetvar = (str); free(var); (var) = freesetvar; } while(0) 
     47 
     48#ifdef __cplusplus 
     49 
     50#ifndef _CPP_CSTRING 
     51#include <cstring> 
     52#endif 
     53#ifndef _CPP_CSTDLIB 
     54#include <cstdlib> 
     55#endif 
     56 
     57inline char *nulldup(const char *str)                           { return str ? strdup(str) : NULL; } // this does the same as GB_strdup 
     58inline void freedup(char *& strvar, const char *no_heapcopy)    { char *tmp_copy = nulldup(no_heapcopy); free(strvar); strvar = tmp_copy; } 
     59inline void reassign(char *& dstvar, char *& srcvar)            { freeset(dstvar, srcvar); srcvar = NULL; } 
     60 
     61#else 
     62 
     63#define nulldup(str)        GB_strdup(str) 
     64#define freedup(var,str)    freeset(var, nulldup(str)) 
     65#define reassign(dvar,svar) do { freeset(dvar, svar); (svar) = NULL; } while(0) 
     66 
     67#endif 
     68/* -------------------------------------------------------------------------------- */ 
     69 
     70 
    3071#ifndef P_ 
    3172#define P_(s) s 
  • trunk/ARB_GDE/GDE_arbdb_io.cxx

    r5330 r5725  
    216216            { 
    217217                AppendNA((NA_Base *)sequfilt[number],strlen((const char *)sequfilt[number]),this_elem); 
    218                 free(sequfilt[number]); 
    219                 sequfilt[number] = 0; 
     218                freeset(sequfilt[number], 0); 
    220219            } 
    221220 
  • trunk/ARB_GDE/GDE_event.cxx

    r5708 r5725  
    139139            strncat(temp,textvalue,strlen(textvalue)); 
    140140            strcat( temp,&(Action[i+strlen(symbol)]) ); 
    141             free(Action); 
    142             Action = temp; 
    143         } 
    144         else 
    145         { 
     141            freeset(Action, temp); 
     142        } 
     143        else { 
    146144            if (warned_about.find(symbol) == warned_about.end()) { 
    147145                fprintf(stderr, 
     
    151149                warned_about.insert(symbol); 
    152150            } 
    153             //             newlen = strlen(Action)-strlen(symbol) 
    154             //                 +strlen(method)+1; 
    155             //             temp   = (char *)calloc(newlen,1); 
    156             //             if (temp == NULL) 
    157             //                 Error("ReplaceArgs():Error in calloc"); 
    158             //             strncat(temp,Action,i); 
    159             //             strncat(temp,method,strlen(method)); 
    160             //             strcat( temp,&(Action[i+strlen(symbol)]) ); 
    161             //             free(Action); 
    162             //             Action = temp; 
    163151        } 
    164152    } 
     
    183171} 
    184172 
    185 static void GDE_free(void **p) 
    186 { 
    187     if(*p!=0) 
    188     { 
    189         //delete *p; 
    190         free(*p); 
    191         *p=0; 
    192     } 
    193 } 
    194  
    195 /*void GDE_freemask(GMask *mask) 
    196   { 
    197   if(mask==0) return; 
    198   GDE_free((void**)&mask->name); 
    199   for(long i=0;i<mask->listlen;i++) 
    200   { 
    201   NumList numl=mask->list[i]; 
    202   GDE_free((void**)&numl.valu); 
    203   } 
    204   GDE_free((void**)&mask->list); 
    205   }*/ 
     173static void GDE_free(void **p) { 
     174    freeset(*p, NULL); 
     175} 
    206176 
    207177static char *ReplaceFile(char *Action,GfileFormat file) 
     
    221191        strncat(temp,method,strlen(method)); 
    222192        strcat( temp,&(Action[i+strlen(symbol)]) ); 
    223         free(Action); 
    224         Action = temp; 
     193        freeset(Action, temp); 
    225194    } 
    226195    return(Action); 
     
    246215        strncat(temp,method,strlen(method)); 
    247216        strcat( temp,&(Action[i+strlen(symbol)]) ); 
    248         free(Action); 
    249         Action = temp; 
     217        freeset(Action, temp); 
    250218    } 
    251219    return(Action); 
     
    253221 
    254222 
    255 static void GDE_freesequ(NA_Sequence *sequ) 
    256 { 
    257     if(sequ==0) return; 
    258     GDE_free((void**)&sequ->comments); 
    259     /* GDE_free((void**)&sequ->col_lut);    OLIVER STRUNK       */ 
    260     GDE_free((void**)&sequ->cmask); 
    261     /*GDE_freemask(sequ->mask);*/ 
    262     GDE_free((void**)&sequ->baggage); 
    263     GDE_free((void**)&sequ->sequence); 
    264     /*if(sequ->groupf) 
    265       { 
    266       GDE_freesequ(sequ->groupf); 
    267       GDE_free((void**)&sequ->groupf); 
    268       }*/ 
    269 } 
    270  
    271 static void GDE_freeali(NA_Alignment *dataset) 
    272 { 
    273     if(dataset==0) return; 
    274     GDE_free((void**)&dataset->id); 
    275     GDE_free((void**)&dataset->description); 
    276     GDE_free((void**)&dataset->authority); 
    277     GDE_free((void**)&dataset->cmask); 
    278     GDE_free((void**)&dataset->selection_mask); 
    279     GDE_free((void**)&dataset->alignment_name); 
    280  
    281     /* maybe not correct: 
    282        GMask *mask=dataset->mask; 
    283        GDE_freemask(dataset->mask); 
    284        GDE_free((void**)&dataset->mask);*/ 
    285  
    286     unsigned long i; 
    287     // **maybe not correct: 
    288     //NA_Sequence **group=dataset->group; 
    289     //for(long i=0;i<dataset->numgroups;i++) 
    290     //  GDE_freesequ(dataset->group[i]); 
    291     //GDE_free((void**)&dataset->group); 
    292     // **correction: this was not correct 
    293  
    294     for(i=0;i<dataset->numelements;i++) 
    295         GDE_freesequ(&(dataset->element[i])); 
     223static void GDE_freesequ(NA_Sequence *sequ) { 
     224    if (sequ) { 
     225        GDE_free((void**)&sequ->comments); 
     226        GDE_free((void**)&sequ->cmask); 
     227        GDE_free((void**)&sequ->baggage); 
     228        GDE_free((void**)&sequ->sequence); 
     229    } 
     230} 
     231 
     232static void GDE_freeali(NA_Alignment *dataset) { 
     233    if (dataset) { 
     234        GDE_free((void**)&dataset->id); 
     235        GDE_free((void**)&dataset->description); 
     236        GDE_free((void**)&dataset->authority); 
     237        GDE_free((void**)&dataset->cmask); 
     238        GDE_free((void**)&dataset->selection_mask); 
     239        GDE_free((void**)&dataset->alignment_name); 
     240 
     241        unsigned long i; 
     242        for(i=0;i<dataset->numelements;i++) GDE_freesequ(&(dataset->element[i])); 
     243    } 
    296244} 
    297245 
     
    524472        DataSet->gb_main = GLOBAL_gb_main; 
    525473        GB_begin_transaction(DataSet->gb_main); 
    526         delete DataSet->alignment_name; 
    527         DataSet->alignment_name = GBT_get_default_alignment(DataSet->gb_main); 
    528         free(alignment_name); 
    529         alignment_name = strdup(DataSet->alignment_name); 
     474        freeset(DataSet->alignment_name, GBT_get_default_alignment(DataSet->gb_main)); 
     475        freedup(alignment_name, DataSet->alignment_name); 
    530476 
    531477        aw_status("reading database"); 
     
    673619 
    674620    GDE_freeali(DataSet); 
    675     free(DataSet); 
    676     DataSet             = 0; 
    677     DataSet             = (NA_Alignment *) Calloc(1,sizeof(NA_Alignment)); 
     621    freeset(DataSet, (NA_Alignment *)Calloc(1,sizeof(NA_Alignment))); 
    678622    DataSet->rel_offset = 0; 
    679  
    680     //     aw->hide(); 
    681 } 
    682  
     623} 
     624 
  • trunk/AWT/AWT_advice.cxx

    r5675 r5725  
    115115    size_t  message_len = strlen(message); awt_assert(message_len>0); 
    116116    long    crc32       = GB_checksum(message, message_len, true, " .,-!"); // checksum is used to test if advice was shown 
    117     char   *advice_id   = GB_strdup(GBS_global_string("%lx", crc32)); 
     117    char   *advice_id   = GBS_global_string_copy("%lx", crc32); 
    118118 
    119119    bool show_advice = !advice_disabled(advice_id); 
  • trunk/AWT/AWT_asciiprint.cxx

    r5695 r5725  
    160160    AW_root *awr  = aww->get_root(); 
    161161    char    *text = awr->awar(AWAR_APRINT_TEXT)->read_string(); 
    162     { 
    163         char *rtext = GBS_replace_tabs_by_spaces(text); 
    164         free(text); 
    165         text = rtext; 
    166     } 
     162 
     163    freeset(text, GBS_replace_tabs_by_spaces(text)); 
    167164 
    168165    AWT_asciiprint_destination dest = (AWT_asciiprint_destination)awr->awar(AWAR_APRINT_PRINTTO)->read_int(); 
  • trunk/AWT/AWT_config_manager.cxx

    r5675 r5725  
    105105    char *corrected = GBS_string_2_key(name); 
    106106 
    107     if (strcmp(corrected, "__") == 0) { 
    108         free(corrected); 
    109         corrected = strdup(""); 
    110     } 
    111  
     107    if (strcmp(corrected, "__") == 0) freedup(corrected, ""); 
    112108    return corrected; 
    113109} 
  • trunk/AWT/AWT_db_browser.cxx

    r5675 r5725  
    561561            if (strlen(content)>(ENTRY_MAX_LENGTH+15)) { 
    562562                content[ENTRY_MAX_LENGTH] = 0; 
    563                 char *shortened_content   = GBS_global_string_copy("%s [rest skipped]", content); 
    564                 free(content); 
    565                 content                   = shortened_content; 
     563                freeset(content, GBS_global_string_copy("%s [rest skipped]", content)); 
    566564            } 
    567565 
  • trunk/AWT/AWT_dtree.cxx

    r5660 r5725  
    671671                    char *new_gname = aw_input("Rename group", 0, at->name); 
    672672                    if (new_gname) { 
    673                         free(at->name); 
    674                         at->name = new_gname; 
     673                        freeset(at->name, new_gname); 
    675674                        GB_write_string(gb_name, new_gname); 
    676675                    } 
     
    25142513    use_ellipse        = aw_root->awar(AWAR_DTREE_USE_ELLIPSE)->read_int(); 
    25152514 
    2516     free(species_name); 
    2517     species_name = aw_root->awar(AWAR_SPECIES_NAME)->read_string(); 
     2515    freeset(species_name, aw_root->awar(AWAR_SPECIES_NAME)->read_string()); 
    25182516 
    25192517    x_cursor = y_cursor = 0.0; 
  • trunk/AWT/AWT_file_selection.cxx

    r5695 r5725  
    146146    if (!lslash) return 0; 
    147147 
    148     char *result        = GB_strdup(path); 
     148    char *result        = strdup(path); 
    149149    result[lslash-path] = 0; 
    150150 
     
    304304 
    305305    if (name[0] == '/' && AWT_is_dir(name)) { 
    306         free(fulldir); 
    307         fulldir   = strdup(name); 
     306        freedup(fulldir, name); 
    308307        name_only = ""; 
    309308    } 
     
    474473                    } 
    475474                    else { 
    476                         free(cbs->previous_filename); 
    477                         cbs->previous_filename = 0; 
     475                        freeset(cbs->previous_filename, 0); 
    478476                        aw_root->awar(cbs->def_name)->write_string(newName); 
    479477                    } 
    480478 
    481                     free(newName); 
    482                     newName = aw_root->awar(cbs->def_name)->read_string(); 
     479                    freeset(newName, aw_root->awar(cbs->def_name)->read_string()); 
    483480                } 
    484481                else { 
     
    512509                                if (suffix[-1] == '.') suffix[-1] = 0; 
    513510                            } 
    514  
    515                             char *n = set_suffix(newName, pfilter); 
    516                             free(newName); 
    517                             newName = n; 
     511                            freeset(newName, set_suffix(newName, pfilter)); 
    518512                        } 
    519513                    } 
     
    524518                    aw_root->awar(cbs->def_name)->write_string(newName); // loops back if changed !!! 
    525519                } 
    526                  
    527                 free(cbs->previous_filename); 
    528                 cbs->previous_filename = newName; // this releases newName 
     520 
     521                freeset(cbs->previous_filename, newName); 
    529522            } 
    530523        } 
     
    663656        if (!dir[0]) {          // empty -> fillin current dir 
    664657            awar_dir->write_string(GB_getcwd()); 
    665             free(dir); 
    666             dir = awar_dir->read_string(); 
     658            freeset(dir, awar_dir->read_string()); 
    667659        } 
    668660 
  • trunk/AWT/AWT_filter.cxx

    r5660 r5725  
    316316 
    317317        if (strstr(content, "none")==0) { // don't add filters named 'none' 
    318             char *new_combined_name = (char*)malloc(strlen(combined_name)+1+strlen(content)+1); 
    319             sprintf(new_combined_name, "%s/%s", combined_name, content); 
    320             free(combined_name); 
    321             combined_name = new_combined_name; 
     318            freeset(combined_name, GBS_global_string_copy("%s/%s", combined_name, content)); 
    322319        } 
    323320    } 
  • trunk/AWT/AWT_imp_exp.cxx

    r5564 r5725  
    106106                boot = GBS_global_string("%i", int(val+0.5)); 
    107107            } 
    108             bootstrap = GB_strdup(boot); 
     108            bootstrap = strdup(boot); 
    109109        } 
    110110 
     
    157157                char   *end = 0; 
    158158                double  val = strtod(boot, &end); 
    159                 awt_assert(end[0] == '%'); // otherwise sth strange is contained in remark_branch 
    160                 boot        = GBS_global_string("%i", int(val+0.5)); 
    161  
    162                 bootstrap = GB_strdup(boot); 
     159                 
     160                awt_assert(end[0] == '%');          // otherwise sth strange is contained in remark_branch 
     161                bootstrap = GBS_global_string_copy("%i", int(val+0.5)); 
    163162            } 
    164163        } 
     
    171170 
    172171            awt_assert(buf); 
    173             groupname = GB_strdup(buf); 
     172            groupname = strdup(buf); 
    174173 
    175174            GBDATA *gb_grouped = GB_entry(tree->gb_node, "grouped"); 
     
    192191            if (bootstrap) { 
    193192                branch_tag.add_attribute("bootstrap", bootstrap); 
    194                 free(bootstrap); 
    195                 bootstrap = 0; 
     193                freeset(bootstrap, 0); 
    196194            } 
    197195            if (groupname) { 
    198196                branch_tag.add_attribute("groupname", groupname); 
    199                 free(groupname); 
    200                 groupname = 0; 
     197                freeset(groupname, 0); 
    201198                if (folded) branch_tag.add_attribute("folded", "1"); 
    202199            } 
     
    317314 
    318315                if (tree_remark) remark = GB_read_string(tree_remark); 
    319                 else remark             = GB_strdup(GBS_global_string("ARB-tree '%s'", tree_name)); 
     316                else remark             = GBS_global_string_copy("ARB-tree '%s'", tree_name); 
    320317 
    321318                { 
  • trunk/AWT/AWT_nds.cxx

    r5708 r5725  
    557557 
    558558        if (at_leaf || at_group) { 
    559             if (awt_nds_ms->dkeys[count]) free(awt_nds_ms->dkeys[count]); 
    560             awt_nds_ms->dkeys[count] = GB_read_string(GB_entry(gbz, "key_text")); 
     559            freeset(awt_nds_ms->dkeys[count], GB_read_string(GB_entry(gbz, "key_text"))); 
    561560 
    562561            awt_nds_ms->rek[count]      = (GB_first_non_key_char(awt_nds_ms->dkeys[count]) != 0); 
     
    566565 
    567566            gbe = GB_entry(gbz, "pars"); 
    568             if (awt_nds_ms->parsing[count]) { 
    569                 free(awt_nds_ms->parsing[count]); 
    570                 awt_nds_ms->parsing[count] = 0; 
    571             } 
     567            freeset(awt_nds_ms->parsing[count], 0); 
    572568            if (gbe && GB_read_string_count(gbe)>1 ) awt_nds_ms->parsing[count] = GB_read_string(gbe); 
    573569            count++; 
     
    673669            if (aci_srt) { 
    674670                char *aci_result = GB_command_interpreter(gb_main, str, aci_srt, gbd, tree_name); 
    675                 if (aci_result) { 
    676                     free(str); 
    677                     str = aci_result; 
    678                 } 
    679                 else {          // error 
    680                     error = GB_get_error(); 
    681                     free(str); 
    682                     str   = GBS_global_string_copy("<error: %s>", error); 
    683                 } 
     671                freeset(str, aci_result ? aci_result : GBS_global_string_copy("<error: %s>", GB_expect_error())); 
    684672            } 
    685673        } 
  • trunk/AWT/AWT_nei.cxx

    r5708 r5725  
    133133PH_NEIGHBOURJOINING::~PH_NEIGHBOURJOINING(void) 
    134134{ 
    135 //     long i; 
    136 //     for (i=0;i<size;i++) { 
    137 //         free(dist_matrix[i]); 
    138 //         dist_matrix[i] = 0; 
    139 //     } 
    140135    delete [] dist_matrix; 
    141  
    142 //     free((char *)dist_list); 
    143136    delete [] dist_list; 
    144137    free((char *)net_divergence); 
  • trunk/AWT/AWT_pro_a_nucs.cxx

    r5708 r5725  
    221221 
    222222    { 
    223         char *D_codons = GB_strdup(AWT_get_codons('D', code_nr)); 
    224         char *N_codons = GB_strdup(AWT_get_codons('N', code_nr)); 
    225         char *E_codons = GB_strdup(AWT_get_codons('E', code_nr)); 
    226         char *Q_codons = GB_strdup(AWT_get_codons('Q', code_nr)); 
     223        char *D_codons = strdup(AWT_get_codons('D', code_nr)); 
     224        char *N_codons = strdup(AWT_get_codons('N', code_nr)); 
     225        char *E_codons = strdup(AWT_get_codons('E', code_nr)); 
     226        char *Q_codons = strdup(AWT_get_codons('Q', code_nr)); 
    227227 
    228228        char protein; 
  • trunk/AWT/AWT_query_and_functions.cxx

    r5660 r5725  
    762762                long use_tag = cbs->aws->get_root()->awar(cbs->awar_use_tag)->read_int(); 
    763763                if (!use_tag || !strlen(tag)) { 
    764                     free(tag); 
    765                     tag = 0; 
     764                    freeset(tag, 0); 
    766765                } 
    767766            } 
     
    11191118        if (size >= buffersize) { 
    11201119            buffersize = int(size*1.5); 
    1121             free(buffer); 
    1122             buffer     = (char*)malloc(buffersize); 
     1120            freeset(buffer, (char*)malloc(buffersize)); 
    11231121        } 
    11241122 
     
    13441342    else                                    aws->callback(awt_colorize_marked, (AW_CL)cmd); 
    13451343 
    1346     aws->create_autosize_button("COLORIZE", GB_strdup(GBS_global_string("Set color of %s %s to ...", what, Sel->items_name)), "S", 2); 
     1344    aws->create_autosize_button("COLORIZE", GBS_global_string_copy("Set color of %s %s to ...", what, Sel->items_name), "S", 2); 
    13471345 
    13481346    { 
     
    13701368        aws->at("mark"); 
    13711369        aws->callback(awt_mark_colored, (AW_CL)cmd, (AW_CL)1); 
    1372         aws->create_autosize_button("MARK_COLORED", GB_strdup(GBS_global_string("Mark all %s of ...", Sel->items_name)), "M", 2); 
     1370        aws->create_autosize_button("MARK_COLORED", GBS_global_string_copy("Mark all %s of ...", Sel->items_name), "M", 2); 
    13731371 
    13741372        aws->at("unmark"); 
    13751373        aws->callback(awt_mark_colored, (AW_CL)cmd, (AW_CL)0); 
    1376         aws->create_autosize_button("UNMARK_COLORED", GB_strdup(GBS_global_string("Unmark all %s of ...", Sel->items_name)), "U", 2); 
     1374        aws->create_autosize_button("UNMARK_COLORED", GBS_global_string_copy("Unmark all %s of ...", Sel->items_name), "U", 2); 
    13771375 
    13781376        aws->at("invert"); 
    13791377        aws->callback(awt_mark_colored, (AW_CL)cmd, (AW_CL)2); 
    1380         aws->create_autosize_button("INVERT_COLORED", GB_strdup(GBS_global_string("Invert all %s of ...", Sel->items_name)), "I", 2); 
     1378        aws->create_autosize_button("INVERT_COLORED", GBS_global_string_copy("Invert all %s of ...", Sel->items_name), "I", 2); 
    13811379    } 
    13821380 
     
    13941392    return create_awt_colorizer_window(aw_root, gb_main, 0, sel); 
    13951393} 
    1396  
    1397 //     AW_window_simple *aws = new AW_window_simple; 
    1398  
    1399 //     { 
    1400 //         char *macro_name = GB_strdup(GBS_global_string("COLORIZE_%s", sel->items_name)); 
    1401 //         char *title      = GB_strdup(GBS_global_string("Colorize and mark %s", sel->items_name)); 
    1402  
    1403 //         aws->init(aw_root, macro_name, title, 100, 100); 
    1404  
    1405 //         free(title); 
    1406 //         free(macro_name); 
    1407 //     } 
    1408  
    1409 //     aws->load_xfig("colorize.fig"); 
    1410  
    1411 //     aws->at("close"); 
    1412 //     aws->callback((AW_CB0)AW_POPDOWN); 
    1413 //     aws->create_button("CLOSE","CLOSE","C"); 
    1414  
    1415 //     aws->at("help"); 
    1416 //     aws->callback( AW_POPUP_HELP,(AW_CL)"colorize_items.hlp"); 
    1417 //     aws->create_button("HELP","HELP","H"); 
    1418  
    1419 // #if 0 
    1420 //     aws->at("color"); 
    1421 //     aws->create_option_menu(AWAR_CURRENT_COLOR); 
    1422 //     for (int i = 1; i <= AW_COLOR_GROUPS; ++i) { 
    1423 //         aws->insert_option(AW_get_color_group_name(aw_root, i), 0, i); 
    1424 //     } 
    1425 //     aws->update_option_menu(); 
    1426 // #endif 
    1427  
    1428 //     return aws; 
    1429 // } 
    1430  
    14311394 
    14321395AW_window *create_awt_open_parser(AW_root *aw_root, struct adaqbsstruct *cbs) 
     
    15151478 
    15161479    char *value = cbs->aws->get_root()->awar(cbs->awar_setvalue)->read_string(); 
    1517     if (value[0] == 0) { 
    1518         free(value); 
    1519         value = 0; 
    1520     } 
     1480    if (value[0] == 0) freeset(value, 0); 
    15211481 
    15221482    GB_begin_transaction(cbs->gb_main); 
  • trunk/AWT/AWT_sel_boxes.cxx

    r5660 r5725  
    510510        } 
    511511        const char *name = GB_read_char_pntr(gb_name); 
    512         if (result) { 
    513             char *neu = GB_strdup(GBS_global_string("%s;%s", result, name)); 
    514             free(result); 
    515             result    = neu; 
    516         } 
    517         else { 
    518             result = GB_strdup(name); 
    519         } 
     512        awt_assert(name); 
     513         
     514        if (result) freeset(result, GBS_global_string_copy("%s;%s", result, name)); 
     515        else result = strdup(name); 
    520516    } 
    521517    GB_pop_transaction(gb_main); 
  • trunk/AWT/AWT_seq_colors.cxx

    r5628 r5725  
    261261    if (len > ref_len){ 
    262262        char *ref2 = (char *)GB_calloc(sizeof(char),len+1); 
    263         if (reference ) strcpy(ref2,reference); 
    264         free(reference); 
     263         
     264        if (reference) { 
     265            strcpy(ref2,reference); 
     266            free(reference); 
     267        } 
    265268        reference = ref2; 
    266         ref_len = len; 
     269        ref_len   = len; 
    267270    } 
    268271} 
  • trunk/AWT/AWT_tree.cxx

    r5708 r5725  
    908908    {           // move remark branches to top 
    909909        AP_tree *node; 
    910         char *remark = GB_strdup(this->remark_branch); 
     910        char *remark = nulldup(this->remark_branch); 
    911911        for (node = this;node->father;node = node->father){ 
    912912            char *sh = node->remark_branch; 
  • trunk/AWTC/AWTC_ClustalV.cxx

    r5497 r5725  
    512512void exit_show_pair(void) 
    513513{ 
    514     free(zzd);   zzd   = 0; 
    515     free(zzc);   zzc   = 0; 
    516     free(zzb);   zzb   = 0; 
    517     free(zza);   zza   = 0; 
    518     free(displ); displ = 0; 
     514    freeset(zzd, 0); 
     515    freeset(zzc, 0); 
     516    freeset(zzb, 0); 
     517    freeset(zza, 0); 
     518    freeset(displ, 0); 
    519519} 
    520520 
     
    575575#ifdef MATRIX_DUMP 
    576576 
    577 static unsigned char *lstr_ss = 0; 
    578 static inline const unsigned char *lstr(const unsigned char *s, int len) 
    579 { 
    580     if (lstr_ss) free(lstr_ss); 
    581     lstr_ss = (unsigned char*)strndup((const char*)s,len); 
     577static inline const unsigned char *lstr(const unsigned char *s, int len) { 
     578    static unsigned char *lstr_ss = 0; 
     579 
     580    freeset(lstr_ss, (unsigned char*)strndup((const char*)s,len)); 
    582581    return lstr_ss; 
    583582} 
  • trunk/AWTC/AWTC_constructSequence.cxx

    r5494 r5725  
    4848} 
    4949 
    50 static inline char *strndup(const char *seq, int length) 
    51 { 
     50static inline char *strndup(const char *seq, int length) { 
    5251    char *neu = new char[length+1]; 
    5352 
     
    5756    return neu; 
    5857} 
    59 static char *lstr_ss = 0; 
    60 static inline const char *lstr(const char *s, int len) 
    61 { 
    62     if (lstr_ss) free(lstr_ss); 
    63     lstr_ss = strndup(s,len); 
     58static inline const char *lstr(const char *s, int len) { 
     59    static char *lstr_ss = 0; 
     60 
     61    freeset(lstr_ss, strndup(s,len)); 
    6462    return lstr_ss; 
    6563} 
  • trunk/AWTC/AWTC_fast_aligner.cxx

    r5675 r5725  
    385385    static char *buffer; 
    386386 
    387     if (alloc<(len+1)) 
    388     { 
     387    if (alloc<(len+1)) { 
    389388        if (alloc) free(buffer); 
    390389        buffer = (char*)malloc(alloc=len+100); 
     
    14591458    } 
    14601459 
    1461     free(*toString); 
    1462     *toString = newString; 
    1463      
     1460    freeset(*toString, newString); 
    14641461    free(currInfo); 
    14651462} 
     
    15201517        while (next_relatives) { 
    15211518            next_relatives--; 
    1522             free(nearestRelative[next_relatives]); 
    1523             nearestRelative[next_relatives] = 0; 
     1519            freeset(nearestRelative[next_relatives], 0); 
    15241520        } 
    15251521 
     
    16711667                } 
    16721668 
    1673                 for (; i<next_relatives; ++i) { // delete superfluous relatives 
    1674                     free(nearestRelative[i]); 
    1675                     nearestRelative[i] = 0; 
    1676                 } 
     1669                // delete superfluous relatives 
     1670                for (; i<next_relatives; ++i) freeset(nearestRelative[i], 0); 
    16771671 
    16781672                if (next_relatives>relSearch.maxRelatives) { 
     
    18061800    delete toAlignSequence; 
    18071801 
    1808     for (i=0; i<next_relatives; i++) { 
    1809         free(nearestRelative[i]); 
    1810         nearestRelative[i] = 0; 
    1811     } 
     1802    for (i=0; i<next_relatives; i++) freeset(nearestRelative[i], 0); 
    18121803    delete [] nearestRelative; 
    18131804 
  • trunk/AWTI/AWTI_export.cxx

    r5695 r5725  
    367367const char *export_sequence_data::get_export_sequence(GBDATA *gb_species, size_t& seq_len, GB_ERROR& err) { 
    368368    if (gb_species != last_species_read) { 
    369         if (error) { 
    370             free(error); 
    371             error = 0; 
    372         } 
     369        freeset(error, 0); 
    373370 
    374371        // read + filter a new species 
     
    633630                aw_message(GB_export_IO_error("deleting", *resulting_outname)); 
    634631            } 
    635             free(*resulting_outname); 
    636         } 
    637         *resulting_outname = 0; 
     632            freeset(*resulting_outname, 0); 
     633        } 
    638634    } 
    639635 
     
    667663                aw_status(fname); 
    668664 
    669                 char *oname = GB_strdup(GB_concat_path(path, fname)); 
     665                char *oname = strdup(GB_concat_path(path, fname)); 
    670666                char *res_oname; 
    671667 
     
    679675                    (res_oname && strcmp(*resulting_outname, res_oname)>0)) // or smaller than set one 
    680676                { 
    681                     free(*resulting_outname); 
    682                     *resulting_outname = res_oname; 
    683                     res_oname          = NULL; 
     677                    reassign(*resulting_outname, res_oname); 
    684678                } 
    685679 
     
    801795 
    802796                    if (suffix) { 
    803                         if (previous_suffix && ARB_stricmp(suffix, previous_suffix) == 0) { // remove old suffix 
    804                             free(suffix); 
    805                             suffix = GB_strdup(current_suffix); 
    806                         } 
    807                         else {  // don't know existing suffix -> append 
    808                             char *new_suffix = GB_strdup(GB_append_suffix(suffix, current_suffix)); 
    809                             free(suffix); 
    810                             suffix = new_suffix; 
    811                         } 
    812                     } 
    813                     else { 
    814                         suffix = GB_strdup(current_suffix); 
    815                     } 
     797                        if (previous_suffix && ARB_stricmp(suffix, previous_suffix) == 0) freedup(suffix, current_suffix); // remove old suffix 
     798                        else freedup(suffix, GB_append_suffix(suffix, current_suffix)); // don't know existing suffix -> append 
     799                    } 
     800                    else suffix = strdup(current_suffix); 
    816801 
    817802                    const char *new_exportname = GB_concat_path(path, GB_append_suffix(nameOnly, suffix)); 
     
    828813                 
    829814                // remember last applied suffix 
    830                 free(previous_suffix); 
    831                 previous_suffix = current_suffix; 
    832                 current_suffix  = 0; 
     815                reassign(previous_suffix, current_suffix); 
    833816            } 
    834817 
  • trunk/AWTI/AWTI_import.cxx

    r5695 r5725  
    790790                char *h = GBS_string_eval(sequence,ifo->sequencesrt,gb_species); 
    791791                if (!h) return GB_get_error(); 
    792                 free(sequence); 
    793                 sequence = h; 
     792                freeset(sequence, h); 
    794793            } 
    795794 
  • trunk/CONSENSUS_TREE/CT_ntree.cxx

    r5390 r5725  
    9797    part_free((tree->part)); 
    9898    tree->part = NULL; 
    99     free((char *)tree); 
    100     tree = NULL; 
     99    freeset(tree, NULL); 
    101100} 
    102101 
  • trunk/DIST/DI_matr.cxx

    r5660 r5725  
    226226char *DI_MATRIX::unload(void) 
    227227{ 
    228     free(use); 
    229     use = 0; 
     228    freeset(use, 0); 
    230229    long i; 
    231230    for (i=0;i<nentries;i++){ 
     
    233232    } 
    234233    delete tree_root; 
    235 //     delete [] entries; 
    236     free(entries); 
    237     entries = 0; 
     234    freeset(entries, 0); 
    238235    nentries = 0; 
    239236    return 0; 
  • trunk/EDIT4/ED4_base.cxx

    r5712 r5725  
    889889    sprintf(name, "%s (%d)",name, counter); 
    890890 
    891     free(consensus_name_terminal->id); 
    892     consensus_name_terminal->id = name; 
     891    freeset(consensus_name_terminal->id, name); 
    893892 
    894893    //    update_species_counters(); 
  • trunk/EDIT4/ED4_cursor.cxx

    r5655 r5725  
    833833                    static char *last_set_SAI = 0; 
    834834                    if (!last_set_SAI || strcmp(last_set_SAI, species_name) != 0) { 
    835                         free(last_set_SAI); 
    836                         last_set_SAI = strdup(species_name); 
     835                        freedup(last_set_SAI, species_name); 
    837836 
    838837                        ignore_selected_SAI_changes_cb = true; 
     
    844843                    static char *last_set_species = 0; 
    845844                    if (!last_set_species || strcmp(last_set_species, species_name) != 0) { 
    846                         free(last_set_species); 
    847                         last_set_species = strdup(species_name); 
     845                        freedup(last_set_species, species_name); 
    848846 
    849847                        ignore_selected_species_changes_cb = true; 
  • trunk/EDIT4/ED4_edit_string.cxx

    r5569 r5725  
    769769                            } 
    770770 
    771                             char *aligned_seq = GB_read_string(gb_data);        // read new sequence 
    772                             ad_err = GB_write_string(gb_data, seq);        // restore old sequence 
    773                             free(seq); 
    774                             seq = aligned_seq;                  // set new sequence 
    775                             changed_flag=1;                     // and mark changed 
     771                            char *aligned_seq = GB_read_string(gb_data); // read new sequence 
     772                            ad_err            = GB_write_string(gb_data, seq); // restore old sequence 
     773 
     774                            freeset(seq, aligned_seq); // set new sequence 
     775                            changed_flag = 1;       // and mark changed 
    776776 
    777777                            { 
     
    819819                            AW_helix *helix = ED4_ROOT->helix; 
    820820 
    821                             if (!helix->has_entries()) { 
    822                                 ad_err = GB_strdup("Got no helix information"); 
    823                             } 
     821                            if (!helix->has_entries()) ad_err = strdup("Got no helix information"); 
    824822                            else if (helix->pairtype(seq_pos) != HELIX_NONE) { 
    825823                                seq_pos = helix->opposite_position(seq_pos); 
    826824                                cursor_jump = ED4_JUMP_KEEP_POSITION; 
    827825                            } 
    828                             else { 
    829                                 ad_err = GB_strdup("Not at helix position"); 
    830                             } 
     826                            else ad_err = strdup("Not at helix position"); 
    831827                            break; 
    832828                        } 
     
    11491145                } 
    11501146            } 
    1151             free(seq); 
    1152             seq = 0; 
     1147            freeset(seq, 0); 
    11531148        } 
    11541149    } 
  • trunk/EDIT4/ED4_main.cxx

    r5712 r5725  
    226226                        if (folded_group_man==group_manager) { // we are the consensus of the folded group 
    227227                            if (folded_group_man->is_in_folded_group()) { // a folded group inside a folded group -> do not show 
    228                                 free(seq); 
    229                                 seq = 0; 
     228                                freeset(seq, 0); 
    230229                            } 
    231230                            else { // group folded but consensus shown -> add '-' before name 
     
    233232 
    234233                                sprintf(new_name, "-%s", name); 
    235                                 free(name); 
    236                                 name = new_name; 
     234                                freeset(name, new_name); 
    237235                                name_len++; 
    238236                            } 
    239237                        } 
    240238                        else { // we are really inside a folded group -> don't show 
    241                             free(seq); 
    242                             seq = 0; 
     239                            freeset(seq, 0); 
    243240                        } 
    244241                    } 
  • trunk/EDIT4/ED4_members.cxx

    r5483 r5725  
    202202        memcpy(new_member_list, memberList, size_of_list*sizeof(*new_member_list)); 
    203203 
    204         free(memberList); 
    205         memberList = new_member_list; 
     204        freeset(memberList, new_member_list); 
    206205        size_of_list = new_size_of_list; 
    207206    } 
  • trunk/EDIT4/ED4_no_class.cxx

    r5712 r5725  
    11851185    } 
    11861186    else { 
    1187         const char *field_name = ED4_ROOT->aw_root->awar(AWAR_FIELD_CHOSEN)->read_string(); 
    1188         char *doneContents = strdup(";"); 
    1189         int tryAgain = 1; 
    1190         int foundField = 0; 
     1187        const char *field_name   = ED4_ROOT->aw_root->awar(AWAR_FIELD_CHOSEN)->read_string(); 
     1188        char       *doneContents = strdup(";"); 
     1189        size_t      doneLen      = 1; 
     1190 
     1191        int tryAgain     = 1; 
     1192        int foundField   = 0; 
    11911193        int foundSpecies = 0; 
    11921194 
     
    12091211 
    12101212                        if (type==GB_STRING) { 
    1211                             char *field_content = GB_read_as_string(gb_field); 
     1213                            char   *field_content     = GB_read_as_string(gb_field); 
     1214                            size_t  field_content_len = strlen(field_content); 
    12121215 
    12131216                            foundField = 1; 
    1214                             if (strlen(field_content)>SIGNIFICANT_FIELD_CHARS) { 
     1217                            if (field_content_len>SIGNIFICANT_FIELD_CHARS) { 
    12151218                                field_content[SIGNIFICANT_FIELD_CHARS] = 0; 
     1219                                field_content_len                      = SIGNIFICANT_FIELD_CHARS; 
    12161220                            } 
    12171221 
     
    12221226                                createGroupFromSelected(field_content, field_name, field_content); 
    12231227                                tryAgain = 1; 
    1224                                 int len = strlen(field_content); 
    1225                                 char *newDone = new char[strlen(doneContents)+len+1+1]; 
    1226                                 sprintf(newDone, "%s%s;", doneContents, field_content); 
    1227                                 free(doneContents); 
    1228                                 doneContents = newDone; 
     1228 
     1229                                int newlen = doneLen + field_content_len + 1; 
     1230                                char *newDone = (char*)malloc(newlen+1); 
     1231                                GBS_global_string_to_buffer(newDone, newlen, "%s%s;", doneContents, field_content); 
     1232                                freeset(doneContents, newDone); 
     1233                                doneLen = newlen; 
    12291234                            } 
    12301235                            free(field_content); 
     
    18241829    return length; 
    18251830} 
    1826 static void freeSpeciesMergeList(SpeciesMergeList sml) 
    1827 { 
     1831static void freeSpeciesMergeList(SpeciesMergeList sml) { 
    18281832    while (sml) { 
    1829         SpeciesMergeList next = sml->next; 
    18301833        free(sml->species_name); 
    1831         free(sml); 
    1832         sml = next; 
     1834        freeset(sml, sml->next); 
    18331835    } 
    18341836} 
     
    19111913                    if (!nameIsUnique(new_species_name, gb_species_data)) { 
    19121914                        if (!existingNames) existingNames = new UniqueNameDetector(gb_species_data); 
    1913                          
    1914                         char *uniqueName = AWTC_makeUniqueShortName(new_species_name, *existingNames); 
    1915                         free(new_species_name); 
    1916                         new_species_name = uniqueName; 
    1917  
     1915                        freeset(new_species_name, AWTC_makeUniqueShortName(new_species_name, *existingNames)); 
    19181916                        if (!new_species_name) error = "No short name created."; 
    19191917                    } 
     
    21452143                                                        free(content); 
    21462144 
    2147                                                         free(new_content); 
    2148                                                         new_content = whole; 
     2145                                                        freeset(new_content, whole); 
    21492146                                                        new_content_len = strlen(new_content); 
    21502147                                                    } 
     
    21682165                                        sprintf(new_doneFields, "%s%s;", doneFields, fieldName); 
    21692166                                        doneLen += fieldLen+1; 
    2170                                         free(doneFields); 
    2171                                         doneFields = new_doneFields; 
     2167                                        freeset(doneFields, new_doneFields); 
    21722168 
    21732169                                        fieldEnd[0] = ';'; 
  • trunk/EDIT4/ED4_protein_2nd_structure.cxx

    r5655 r5725  
    988988    GBDATA         *gb_protstruct = GBT_find_SAI(gb_main, SAI_name); 
    989989 
    990     free(*protstruct); 
    991     *protstruct = 0; 
     990    freeset(*protstruct, 0); 
    992991 
    993992    if (gb_protstruct) { 
  • trunk/EDIT4/ED4_root.cxx

    r5712 r5725  
    13671367    if (size2<=0) err = (char *)GB_get_error(); 
    13681368 
    1369     free(faligner_data->helix_string); 
    1370     faligner_data->helix_string = 0; 
     1369    freeset(faligner_data->helix_string, 0); 
    13711370     
    13721371    if (!err) { 
  • trunk/EDIT4/ED4_search.cxx

    r5708 r5725  
    7777        AW_root *root = ED4_ROOT->aw_root; 
    7878 
    79         free(pattern); 
    80         pattern        = root->awar(awarList->pattern)->read_string(); 
     79        freeset(pattern, root->awar(awarList->pattern)->read_string()); 
     80 
    8181        min_mismatches = root->awar(awarList->min_mismatches)->read_int(); 
    8282        max_mismatches = root->awar(awarList->max_mismatches)->read_int(); 
     
    179179        else { 
    180180            son = &FOUND; 
    181             comment = GB_strdup(pattern_comment); 
     181            comment = nulldup(pattern_comment); 
    182182        } 
    183183    } 
     
    186186        c = 0; 
    187187        son = 0; 
    188         comment = GB_strdup(pattern_comment); 
     188        comment = nulldup(pattern_comment); 
    189189    } 
    190190    brother = 0; 
  • trunk/EDIT4/ED4_text_terminals.cxx

    r5708 r5725  
    236236        int i; 
    237237        for (i=0;i<ED4_G_DRAG;i++){ 
    238             free(colored_strings[i]); 
    239             colored_strings[i] = (char *)malloc(sizeof(char) * (len_of_colored_strings+1)); 
    240  
     238            freeset(colored_strings[i], (char *)malloc(sizeof(char) * (len_of_colored_strings+1))); 
    241239            memset(colored_strings[i],' ',len_of_colored_strings); 
    242240            colored_strings[i][len_of_colored_strings] = 0; 
     
    397395        int i; 
    398396        for (i=0;i<ED4_G_DRAG;i++){ 
    399             free(colored_strings[i]); 
    400             colored_strings[i] = (char *)malloc(sizeof(char) * (len_of_colored_strings+1)); 
    401  
     397            freeset(colored_strings[i], (char *)malloc(sizeof(char) * (len_of_colored_strings+1))); 
    402398            memset(colored_strings[i],' ',len_of_colored_strings); 
    403399            colored_strings[i][len_of_colored_strings] = 0; 
  • trunk/GENOM/EXP_interface.cxx

    r5675 r5725  
    5151 
    5252static void EXP_select_experiment(GBDATA* /*gb_main*/, AW_root *aw_root, const char *item_name) { 
    53     char *name  = GB_strdup(item_name); 
     53    char *name  = strdup(item_name); 
    5454    char *slash = strchr(name, '/'); 
    5555 
     
    6868 
    6969static GBDATA *EXP_find_experiment_by_id(GBDATA *gb_main, const char *id) { 
    70     char   *organism = GB_strdup(id); 
     70    char   *organism = strdup(id); 
    7171    char   *exp     = strchr(organism, '/'); 
    7272    GBDATA *result   = 0; 
     
    146146            if (!gb_species && old_species_marks) { // got all -> clean up 
    147147                GBT_restore_marked_species(GLOBAL_gb_main, old_species_marks); 
    148                 free(old_species_marks); 
    149                 old_species_marks = 0; 
     148                freeset(old_species_marks, 0); 
    150149            } 
    151150 
  • trunk/GENOM/GEN_interface.cxx

    r5660 r5725  
    3131 
    3232void GEN_select_gene(GBDATA* /*gb_main*/, AW_root *aw_root, const char *item_name) { 
    33     char *organism  = GB_strdup(item_name); 
     33    char *organism  = strdup(item_name); 
    3434    char *gene = strchr(organism, '/'); 
    3535 
     
    5151 
    5252static GBDATA *gen_find_gene_by_id(GBDATA *gb_main, const char *id) { 
    53     char   *organism = GB_strdup(id); 
     53    char   *organism = strdup(id); 
    5454    char   *gene     = strchr(organism, '/'); 
    5555    GBDATA *result   = 0; 
     
    142142            if (!gb_organism && old_species_marks) { // got all -> clean up 
    143143                GBT_restore_marked_species(GLOBAL_gb_main, old_species_marks); 
    144                 free(old_species_marks); 
    145                 old_species_marks = 0; 
     144                freeset(old_species_marks, 0); 
    146145            } 
    147146 
  • trunk/GENOM/GEN_map.cxx

    r5660 r5725  
    737737    if (!full_species_name) full_species_name = species_name; 
    738738 
    739     char *full_name = GB_strdup(GBS_global_string("%s [%s]", full_species_name, gene_name)); 
     739    char *full_name = GBS_global_string_copy("%s [%s]", full_species_name, gene_name); 
    740740    char *sequence  = GBT_read_gene_sequence(gb_gene, GB_TRUE); 
    741741     
     
    831831                                    } 
    832832 
    833                                     if (!error) { 
    834                                         free(short_name); 
    835                                         short_name = newName; 
    836                                     } 
    837                                     else { 
    838                                         free(newName); 
    839                                     } 
     833                                    if (!error) freeset(short_name, newName); 
     834                                    else free(newName); 
    840835                                } 
    841836                                else { // different acc, but uses name generated by nameserver 
  • trunk/GENOM/GEN_nds.cxx

    r5330 r5725  
    6565        /* toggle set ? */ 
    6666        if (GB_read_int(GB_entry(gbz, sf))) { 
    67             if (gen_nds_ms->dkeys[count]) free(gen_nds_ms->dkeys[count]); 
    68             gen_nds_ms->dkeys[count] = GB_read_string(GB_entry(gbz, "key_text")); 
     67            freeset(gen_nds_ms->dkeys[count], GB_read_string(GB_entry(gbz, "key_text"))); 
    6968            if (GB_first_non_key_char(gen_nds_ms->dkeys[count])) { 
    7069                gen_nds_ms->rek[count] = 1; 
     
    7675            //          gen_nds_ms->inherit[count] = GB_read_int(GB_entry(gbz, "inherit")); 
    7776            gbe = GB_entry(gbz, "pars"); 
    78             if (gen_nds_ms->parsing[count]) { 
    79                 free(gen_nds_ms->parsing[count]); 
    80                 gen_nds_ms->parsing[count] = 0; 
    81             } 
     77            freeset(gen_nds_ms->parsing[count], 0); 
    8278            if (gbe && GB_read_string_count(gbe)>1 ) gen_nds_ms->parsing[count] = GB_read_string(gbe); 
    8379            count++; 
  • trunk/MERGE/MG_gene_species.cxx

    r5675 r5725  
    104104    static char *cur_field = 0; 
    105105 
    106     if (cur_field) { free(cur_field); cur_field = 0; } 
    107     cur_field = aw_root->awar(AWAR_MERGE_GENE_SPECIES_CURRENT_FIELD)->read_string(); 
     106    freeset(cur_field, aw_root->awar(AWAR_MERGE_GENE_SPECIES_CURRENT_FIELD)->read_string()); 
    108107 
    109108    if (cur_field[0]) return field_awar(cur_field, subfield); 
     
    168167            mg_assert(!result); 
    169168            aci_result = GB_command_interpreter(GLOBAL_gb_merge, "", aci, gb_species, 0); 
    170             if (!aci_result) { 
    171                 error = GB_get_error(); 
    172                 mg_assert(error); 
    173             } 
     169            if (!aci_result) error = GB_expect_error(); 
    174170        } 
    175171        else { 
    176172            if (aci && aci[0]) { 
    177173                aci_result = GB_command_interpreter(GLOBAL_gb_merge, result ? result : "", aci, gb_origin, 0); 
    178                 if (!aci_result) { 
    179                     error = GB_get_error(); 
    180                     mg_assert(error);  
    181                 } 
    182             } 
    183         } 
    184  
    185         if (aci_result) { 
    186             free(result); 
    187             result = aci_result; 
    188         } 
    189     } 
    190  
    191     if (error) { 
    192         free(result); 
    193         result = 0; 
    194     } 
     174                if (!aci_result) error = GB_expect_error(); 
     175            } 
     176        } 
     177 
     178        if (aci_result) freeset(result, aci_result); 
     179    } 
     180 
     181    if (error) freeset(result, 0); 
    195182 
    196183    mg_assert(result||error); 
     
    278265} 
    279266 
    280 // --------------------------------------------------------- 
    281 //      static void MG_update_example(AW_root *aw_root) 
    282 // --------------------------------------------------------- 
    283267static void MG_update_example(AW_root *aw_root) { 
    284268    char     *result       = 0; 
     
    286270    char     *curr_species = aw_root->awar(MG_left_AWAR_SPECIES_NAME())->read_string(); 
    287271 
    288     if (!curr_species || !curr_species[0]) { 
    289         error = "No species selected."; 
    290     } 
     272    if (!curr_species || !curr_species[0]) error = "No species selected."; 
    291273    else { 
    292274        GB_transaction  dummy(GLOBAL_gb_merge); 
     
    301283 
    302284    if (!error && !result) error = "no result"; 
    303     if (error) { 
    304         free(result); 
    305         result = GBS_global_string_copy("<%s>", error); 
    306     } 
     285    if (error) freeset(result, GBS_global_string_copy("<%s>", error)); 
    307286 
    308287    aw_root->awar(AWAR_MERGE_GENE_SPECIES_EXAMPLE)->write_string(result); 
     
    310289    free(result); 
    311290} 
    312 // ----------------------------------------------------------------------- 
    313 //      static void check_and_correct_current_field(char*& cur_field) 
    314 // ----------------------------------------------------------------------- 
     291 
    315292static void check_and_correct_current_field(char*& cur_field) { 
    316293    if (ARB_stricmp(cur_field, "name") == 0 || ARB_stricmp(cur_field, "acc") == 0) { 
    317294        aw_message("rules writing to 'name' or 'acc' are not allowed."); 
    318  
    319         char *new_cur_field = new char[strlen(cur_field)+3]; 
    320         sprintf(new_cur_field, "%s_2", cur_field); 
    321         free(cur_field); 
    322         cur_field           = new_cur_field; 
     295        freeset(cur_field, GBS_global_string_copy("%s_not_allowed", cur_field)); 
    323296    } 
    324297} 
     
    327300static bool allow_callbacks = true; 
    328301 
    329 // ----------------------------------------------------------------------- 
    330 //      static void MG_current_field_def_changed_cb(AW_root *aw_root) 
    331 // ----------------------------------------------------------------------- 
    332302static void MG_current_field_def_changed_cb(AW_root *aw_root) { 
    333303    if (allow_callbacks) { 
  • trunk/MERGE/MG_preserves.cxx

    r5675 r5725  
    5151    for (i = 0; src_ali_names[i]; ++i) { 
    5252        GBDATA *gb_ali_name = GB_find_string(gb_presets, "alignment_name", src_ali_names[i], GB_IGNORE_CASE, down_2_level); 
    53         if (!gb_ali_name) { 
    54             free(src_ali_names[i]); 
    55             src_ali_names[i] = 0; 
    56         } 
     53        if (!gb_ali_name) freeset(src_ali_names[i], 0); 
    5754    } 
    5855 
  • trunk/MERGE/MG_species.cxx

    r5660 r5725  
    10171017                ++d; 
    10181018            } 
    1019             else { 
    1020                 free(D_alignment_names[s]); 
    1021                 D_alignment_names[s] = 0; 
    1022             } 
     1019            else freeset(D_alignment_names[s], 0); 
    10231020            free(type2); 
    10241021        } 
     
    11121109    GBDATA *M_species; 
    11131110    GBDATA *D_species; 
    1114     free(m_name); m_name = 0; 
     1111    freeset(m_name, 0); 
    11151112 
    11161113    { 
     
    11431140 
    11441141                mg_assert(newname); 
    1145  
    1146                 free(m_name); 
    1147                 m_name = newname; 
     1142                freeset(m_name, newname); 
    11481143            } 
    11491144            else { 
     
    11721167                        free(newname); 
    11731168 
    1174                         free(m_name); 
    1175                         m_name = aw_input("New name of species",NEW_NAME_AWAR); 
    1176  
     1169                        freeset(m_name, aw_input("New name of species", NEW_NAME_AWAR)); 
    11771170                        goto new_try; 
    11781171                    } 
  • trunk/MULTI_PROBE/MP_Window.cxx

    r5625 r5725  
    137137 
    138138    static char *word_buffer = 0; 
    139     if (word_buffer) free(word_buffer); 
    140     word_buffer              = (char*)malloc(wordlen+1); 
    141     memcpy(word_buffer, line, wordlen); 
    142     word_buffer[wordlen]     = 0; 
     139    freeset(word_buffer, GB_strndup(line, wordlen)); 
    143140 
    144141    line = behind_word; 
  • trunk/MULTI_PROBE/MP_probe.cxx

    r3549 r5725  
    294294    result_struct *elem; 
    295295 
    296     for (i=0; i<size_sonden_array; i++) 
    297         free(sondenarray[i]); 
    298  
    299     for (i=0; i<pool_length; i++) 
    300         delete probe_pool[i]; 
     296    for (i=0; i<size_sonden_array; i++) free(sondenarray[i]); 
     297    for (i=0; i<pool_length; i++) delete probe_pool[i]; 
    301298 
    302299    elem = computation_result_list->get_first(); 
    303     while (elem) 
    304     { 
     300    while (elem) { 
    305301        computation_result_list->remove_first(); 
    306302        delete [] elem->view_string; 
     
    311307    delete computation_result_list; 
    312308 
    313     if (act_generation == child_generation) 
    314         delete act_generation; 
    315     else 
    316     { 
     309    if (act_generation == child_generation) delete act_generation; 
     310    else { 
    317311        delete act_generation; 
    318312        delete child_generation; 
  • trunk/MULTI_PROBE/MP_sonde.cxx

    r5003 r5725  
    8282 
    8383    mp_pd_gl.link = (aisc_com *)aisc_open(servername, &mp_pd_gl.com,AISC_MAGIC_NUMBER); 
    84     free (servername); servername = 0; 
     84    freeset(servername, 0); 
    8585 
    8686    if (!mp_pd_gl.link) { 
  • trunk/NALIGNER/ali_main.cxx

    r4932 r5725  
    307307                align_profile = new ALI_PROFILE(align_sequence,&aligs.prof_context); 
    308308 
    309                 /* 
     309                /*  
    310310                 * write information about the profile to the database 
    311311                 */ 
     
    313313                char *String = align_profile->cheapest_sequence(); 
    314314                aligs.arbdb.put_extended("ALI_CON",String); 
    315                 free(String); 
    316                 String = align_profile->borders_sequence(); 
     315                freeset(String, align_profile->borders_sequence()); 
    317316                //                              aligs.arbdb.put_extended("ALI_BOR",string,0); 
    318317                free(String); 
     
    343342                String = align_pre_sequence_i->string(); 
    344343                aligs.arbdb.put_extended("ALI_PRE_I",String); 
    345                 free(String); 
    346                 String = align_pre_sequence->string(); 
     344                freeset(String, align_pre_sequence->string()); 
    347345                aligs.arbdb.put_extended("ALI_PRE",String); 
    348346                free(String); 
  • trunk/NALIGNER/ali_pathmap.cxx

    r4912 r5725  
    2727    unsigned long   l; 
    2828 
    29     if (pathmap) 
    30         free((char *) pathmap); 
     29    if (pathmap) free((char *) pathmap); 
    3130    if (up_pointers) { 
    3231        for (l = 0; l < width; l++) 
  • trunk/NAMES/names.cxx

    r5356 r5725  
    584584 
    585585    parsed_sym = GBS_string_eval(full_name, "\t= :* * *sym*=S",0); 
    586     if (strlen(parsed_sym)>1) { 
    587         free(parsed_sym); 
    588         parsed_sym = strdup(""); 
    589     } 
     586    if (strlen(parsed_sym)>1) freedup(parsed_sym, ""); 
    590587 
    591588    parsed_acc      = make_alnum(locs->acc); 
     
    594591    rest_of_name    = make_alnum(parsed_name+strlen(first_name)); 
    595592 
    596     { 
    597         char *first_name_an = make_alnum(first_name); 
    598         free(first_name); 
    599         first_name = first_name_an; 
    600     } 
     593    freeset(first_name, make_alnum(first_name)); 
    601594 
    602595    assert_alnum(parsed_acc); 
     
    649642{ 
    650643    static char *shrt = 0; 
    651     if (shrt) { 
    652         free(shrt); 
    653         shrt = 0; 
    654     } 
     644 
     645    freeset(shrt, 0); 
    655646 
    656647    NameInformation  info(locs); 
     
    706697            gb_assert(first_short); 
    707698            if (first_short[0] == 0) { // empty? 
    708                 free(first_short); 
    709                 first_short = strdup("Xxx"); 
     699                freedup(first_short, "Xxx"); 
    710700            } 
    711701            first_len = strlen(first_short); 
     
    746736        int both_len = first_len+second_len; 
    747737        if (both_len<8) { 
    748             char *new_second  = GBS_global_string_copy("%s00000000", second_short); 
    749             free(second_short); 
    750             second_short      = new_second; 
    751             second_len       += 8; 
    752             both_len         += 8; 
     738            freeset(second_short, GBS_global_string_copy("%s00000000", second_short)); 
     739            second_len += 8; 
     740            both_len   += 8; 
    753741        } 
    754742 
  • trunk/NTREE/AP_cprofile.cxx

    r5634 r5725  
    200200static void CPRO_deallocate(char **&speciesdata,GBDATA **&speciesdatabase) 
    201201{ 
    202     for (long i=0;i<CPRO.numspecies;i++) { 
    203         if (speciesdata[i]) { 
    204             free(speciesdata[i]); 
    205             speciesdata[i]=0; 
    206         } 
    207     } 
    208     free(speciesdata); speciesdata=0; 
     202    for (long i=0;i<CPRO.numspecies;i++) freeset(speciesdata[i], 0); 
     203    freeset(speciesdata, 0); 
    209204 
    210205    free(speciesdatabase); 
     
    226221{ 
    227222    for(long j=0;j<CPRO.result[which_statistic].resolution*3;j++) { 
    228         if(CPRO.result[which_statistic].statistic[j]) { 
    229             delete(CPRO.result[which_statistic].statistic[j]); 
    230             CPRO.result[which_statistic].statistic[j]=0; 
    231         } 
    232     } 
    233     free(CPRO.result[which_statistic].statistic); 
    234     CPRO.result[which_statistic].statistic=0; 
     223        freeset(CPRO.result[which_statistic].statistic[j], 0); 
     224    } 
     225    freeset(CPRO.result[which_statistic].statistic, 0); 
    235226} 
    236227 
     
    263254            } 
    264255        } 
    265         if(hits) { 
    266             memneeded+=CPRO.result[which_statistic].maxalignlen; 
    267         } 
    268         else { 
    269             free(CPRO.result[which_statistic].statistic[base+0]); 
    270             CPRO.result[which_statistic].statistic[base+0]=0; 
    271         } 
    272         if (group) { 
    273             memneeded+=CPRO.result[which_statistic].maxalignlen; 
    274         } 
    275         else { 
    276             free(CPRO.result[which_statistic].statistic[base+1]); 
    277             CPRO.result[which_statistic].statistic[base+1]=0; 
    278         } 
    279         if(different) { 
    280             memneeded+= CPRO.result[which_statistic].maxalignlen; 
    281         } 
    282         else { 
    283             free(CPRO.result[which_statistic].statistic[base+2]); 
    284             CPRO.result[which_statistic].statistic[base+2]=0; 
    285         } 
     256        if (hits) memneeded += CPRO.result[which_statistic].maxalignlen; 
     257        else freeset(CPRO.result[which_statistic].statistic[base+0], 0); 
     258 
     259        if (group) memneeded += CPRO.result[which_statistic].maxalignlen; 
     260        else freeset(CPRO.result[which_statistic].statistic[base+1], 0); 
     261 
     262        if (different) memneeded += CPRO.result[which_statistic].maxalignlen; 
     263        else freeset(CPRO.result[which_statistic].statistic[base+2], 0); 
    286264    } 
    287265    if(!CPRO.result[which_statistic].maxaccu) CPRO.result[which_statistic].maxaccu=1; 
  • trunk/NTREE/AP_csp_2_gnuplot.cxx

    r5695 r5725  
    4646    dir[lslash-fname] = 0; // cut off at last '/' 
    4747 
    48     char *name_prefix  = GB_strdup(lslash+1); 
     48    char *name_prefix  = strdup(lslash+1); 
    4949    char *name_postfix = 0; 
    5050    char *ldot         = strrchr(name_prefix, '.'); 
     51     
    5152    if (ldot) { 
    5253        ldot[0]      = 0; 
    53         name_postfix = GB_strdup(ldot+1); 
    54     } 
    55     if (!ldot || name_prefix[0] == 0) { // no dot or empty name_prefix 
    56         free(name_prefix); 
    57         name_prefix = GB_strdup("*"); 
    58     } 
    59     if (!name_postfix || name_postfix[0] == 0) { 
    60         free(name_postfix); 
    61         name_postfix = GB_strdup("*_gnu"); 
    62     } 
     54        name_postfix = strdup(ldot+1); 
     55    } 
     56    if (!ldot || name_prefix[0] == 0) freedup(name_prefix, "*"); // no dot or empty name_prefix 
     57    if (!name_postfix || name_postfix[0] == 0) freedup(name_postfix, "*_gnu"); 
    6358 
    6459    nt_assert(name_prefix); 
     
    8580    char *found_files = 0; 
    8681    if (!error) { 
    87         char *mask               = GB_strdup(GBS_global_string("%s.*_gnu", name_prefix)); 
     82        char *mask               = GBS_global_string_copy("%s.*_gnu", name_prefix); 
    8883        char *found_prefix_files = overlay_prefix ? GB_find_all_files(dir, mask, GB_FALSE) : 0; 
    8984        free(mask); 
    9085 
    91         mask                      = GB_strdup(GBS_global_string("*.%s", name_postfix)); 
     86        mask                      = GBS_global_string_copy("*.%s", name_postfix); 
    9287        char *found_postfix_files = overlay_postfix ? GB_find_all_files(dir, mask, GB_FALSE) : 0; 
    9388        free(mask); 
     
    9590        if (found_prefix_files) { 
    9691            if (found_postfix_files) { 
    97                 found_files = GB_strdup(GBS_global_string("%s*%s", found_prefix_files, found_postfix_files)); 
     92                found_files = GBS_global_string_copy("%s*%s", found_prefix_files, found_postfix_files); 
    9893            } 
    9994            else { // only found_prefix_files 
     
    190185    if (rdot) pt = string2PlotType(rdot+1); 
    191186 
    192     static char *title  = 0; 
    193     free(title); title = 0; 
     187    static char *title = 0; 
     188    freeset(title, 0); 
    194189 
    195190    if (pt == PT_UNKNOWN) { 
     
    235230    if (!error) { 
    236231        char *fname = aww->get_root()->awar(AP_AWAR_CSP_FILENAME)->read_string(); 
    237         if (!strchr(fname, '/')) { 
    238             char *neu = GB_strdup(GBS_global_string("./%s", fname)); 
    239             free(fname); 
    240             fname     = neu; 
    241         } 
    242  
    243         if (strlen(fname) < 1) { 
    244             error = "Please enter file name"; 
    245         } 
     232 
     233        if (!strchr(fname, '/')) freeset(fname, GBS_global_string_copy("./%s", fname)); 
     234        if (strlen(fname) < 1) error = "Please enter file name"; 
    246235 
    247236        if (mode == 2) {        // delete overlay files 
     
    378367 
    379368                        if (mode == 1) { 
    380                             char *script = GB_strdup(GBS_global_string("gnuplot %s && rm -f %s", command_file, command_file)); 
     369                            char *script = GBS_global_string_copy("gnuplot %s && rm -f %s", command_file, command_file); 
    381370                            GB_xcmd(script, GB_TRUE, GB_TRUE); 
    382371                            free(script); 
  • trunk/NTREE/AP_pos_var_pars.cxx

    r5589 r5725  
    337337    root->awar_string(AWAR_PVP_TREE, "tree_full",AW_ROOT_DEFAULT); 
    338338    root->awar(AWAR_PVP_TREE)->write_string(largest_tree); 
    339     free(largest_tree); largest_tree = 0; 
     339    freeset(largest_tree, 0); 
    340340 
    341341    aws->at("close");aws->callback((AW_CB0)AW_POPDOWN); 
  • trunk/NTREE/NT_concatenate.cxx

    r5660 r5725  
    591591 
    592592                                free(content); 
    593                                 free(new_content); 
    594                                 new_content = whole; 
     593                                freeset(new_content, whole); 
    595594                                new_content_len = strlen(new_content); 
    596595                            } 
     
    614613                sprintf(new_doneFields, "%s%s;", doneFields, fieldName); 
    615614                doneLen += fieldLen+1; 
    616                 free(doneFields); 
    617                 doneFields = new_doneFields; 
     615                freeset(doneFields, new_doneFields); 
    618616                fieldEnd[0] = ';'; 
    619617            } 
     
    710708            if (GBT_find_species_rel_species_data(gb_species_data, new_species_name) != 0) { //if the name is not unique create unique name 
    711709                UniqueNameDetector und(gb_species_data); 
    712                 char *uniqueName = AWTC_makeUniqueShortName(new_species_name, und); 
    713                 free(new_species_name); 
    714                 new_species_name = uniqueName; 
     710                freeset(new_species_name, AWTC_makeUniqueShortName(new_species_name, und)); 
    715711                if (!new_species_name) error = "No short name created."; 
    716712            } 
  • trunk/NTREE/NT_extern.cxx

    r5714 r5725  
    757757 
    758758                if (name) { 
    759                     free(ref_name); 
    760                     ref_name    = name; 
     759                    freeset(ref_name, name); 
    761760                    ref_gb_node = gb_organism; 
    762761                } 
  • trunk/NTREE/NT_main.cxx

    r5692 r5725  
    436436    bool  abort            = false; 
    437437    bool  start_db_browser = true; 
    438     char *browser_startdir = GB_strdup("."); 
     438    char *browser_startdir = strdup("."); 
    439439 
    440440    if (argc>=2) { 
     
    529529                } 
    530530                case 2: {        // Browse 
    531                     char *dir = GB_strdup(full_path); 
    532                     while (dir && !AWT_is_dir(dir)) { 
    533                         char *updir = AWT_extract_directory(dir); 
    534                         free(dir); 
    535                         dir         = updir; 
    536                     } 
     531                    char *dir = nulldup(full_path); 
     532                    while (dir && !AWT_is_dir(dir)) freeset(dir, AWT_extract_directory(dir)); 
    537533 
    538534                    if (dir) { 
    539535                        nt_assert(AWT_is_dir(dir)); 
    540  
    541                         free(browser_startdir); 
    542                         browser_startdir = dir; 
    543                         dir              = 0; 
     536                        reassign(browser_startdir, dir); 
    544537                        start_db_browser = true; 
    545538                    } 
  • trunk/PARSIMONY/AP_tree_edge.cxx

    r5405 r5725  
    674674            text = "100%"; 
    675675        } 
    676         delete son_node->remark_branch; 
    677         delete son_node->Brother()->remark_branch; 
    678         son_node->remark_branch = GB_strdup(text); 
    679         son_node->Brother()->remark_branch = GB_strdup(text); 
    680     } 
    681     delete AP_sequence::static_mutation_per_site[0]; 
    682     delete AP_sequence::static_mutation_per_site[1]; 
    683     delete AP_sequence::static_mutation_per_site[2]; 
    684  
    685     AP_sequence::static_mutation_per_site[0] = 0; 
    686     AP_sequence::static_mutation_per_site[1] = 0; 
    687     AP_sequence::static_mutation_per_site[2] = 0; 
    688  
     676        freedup(son_node->remark_branch, text); 
     677        freedup(son_node->Brother()->remark_branch, text); 
     678    } 
     679     
     680    freeset(AP_sequence::static_mutation_per_site[0], NULL); 
     681    freeset(AP_sequence::static_mutation_per_site[1], NULL); 
     682    freeset(AP_sequence::static_mutation_per_site[2], NULL); 
    689683} 
    690684 
  • trunk/PGT/config_dialog.cxx

    r3978 r5725  
    690690*  CALLBACK - COLOR/TEXT CHANGED 
    691691****************************************************************************/ 
    692 void configDialog::textChangedCallback(Widget widget) 
    693 { 
     692 
     693inline void setColorFromTextWidget(Widget widget, char *& colorStringVar) { 
    694694    int r, g, b; // DUMMY RGB VALUES 
    695  
    696     // CROSSHAIR TEXT-WIDGET CHANGED? 
    697     if(widget == m_crosshairText) 
    698     { 
    699         char *crosshairColorString= XmTextGetString(m_crosshairText); 
    700  
    701         if(hex2rgb(&r, &g, &b, crosshairColorString)) 
    702         { 
    703             if(m_crosshairColorString) free(m_crosshairColorString); 
    704             m_crosshairColorString= crosshairColorString; 
    705         } 
    706         else free(crosshairColorString); 
    707     } 
    708     // UNMARKED TEXT-WIDGET CHANGED? 
    709     else if(widget == m_unmarkedText) 
    710     { 
    711         char *unmarkedColorString= XmTextGetString(m_unmarkedText); 
    712  
    713         if(hex2rgb(&r, &g, &b, unmarkedColorString)) 
    714         { 
    715             if(m_unmarkedColorString) free(m_unmarkedColorString); 
    716             m_unmarkedColorString= unmarkedColorString; 
    717         } 
    718         else free(unmarkedColorString); 
    719     } 
    720     // MARKED TEXT-WIDGET CHANGED? 
    721     else if(widget == m_markedText) 
    722     { 
    723         char *markedColorString= XmTextGetString(m_markedText); 
    724  
    725         if(hex2rgb(&r, &g, &b, markedColorString)) 
    726         { 
    727             if(m_markedColorString) free(m_markedColorString); 
    728             m_markedColorString= markedColorString; 
    729         } 
    730         else free(markedColorString); 
    731     } 
    732     // SELECTED TEXT-WIDGET CHANGED? 
    733     else if(widget == m_selectedText) 
    734     { 
    735         char *selectedColorString= XmTextGetString(m_selectedText); 
    736  
    737         if(hex2rgb(&r, &g, &b, selectedColorString)) 
    738         { 
    739             if(m_selectedColorString) free(m_selectedColorString); 
    740             m_selectedColorString= selectedColorString; 
    741         } 
    742         else free(selectedColorString); 
    743     } 
    744     // INFOTEXT TEXT-WIDGET CHANGED? 
    745     else if(widget == m_textText) 
    746     { 
    747         char *textColorString= XmTextGetString(m_textText); 
    748  
    749         if(hex2rgb(&r, &g, &b, textColorString)) 
    750         { 
    751             if(m_textColorString) free(m_textColorString); 
    752             m_textColorString= textColorString; 
    753         } 
    754         else free(textColorString); 
    755     } 
    756     // PROTEIN-ID TEXT-WIDGET CHANGED? 
    757     else if(widget == m_ID_ProteinText) 
    758     { 
    759         if(m_id_protein) free(m_id_protein); 
    760         m_id_protein= XmTextGetString(m_ID_ProteinText); 
    761     } 
    762     // GENE-ID TEXT-WIDGET CHANGED? 
    763     else if(widget == m_ID_GeneText) 
    764     { 
    765         if(m_id_gene) free(m_id_gene); 
    766         m_id_gene= XmTextGetString(m_ID_GeneText); 
    767     } 
    768     // PROTEIN-TEXT TEXT-WIDGET CHANGED? 
    769     else if(widget == m_info_ProteinText) 
    770     { 
    771         if(m_info_protein) free(m_info_protein); 
    772         m_info_protein= XmTextGetString(m_info_ProteinText); 
    773     } 
    774     // GENE-TEXT TEXT-WIDGET CHANGED? 
    775     else if(widget == m_info_GeneText) 
    776     { 
    777         if(m_info_gene) free(m_info_gene); 
    778         m_info_gene= XmTextGetString(m_info_GeneText); 
    779     } 
    780  
    781  
    782  
    783 //     // GET TEXT FIELD ENTRIES 
    784 //     char *crosshairText= XmTextGetString(m_crosshairText); 
    785 //     char *unmarkedText= XmTextGetString(m_unmarkedText); 
    786 //     char *markedText= XmTextGetString(m_markedText); 
    787 //     char *selectedText= XmTextGetString(m_selectedText); 
    788 //     char *textText= XmTextGetString(m_textText); 
    789 // 
    790 //     char *id_proteinText= XmTextGetString(m_ID_ProteinText); 
    791 //     char *id_geneText= XmTextGetString(m_ID_GeneText); 
    792 //     char *info_proteinText= XmTextGetString(m_info_ProteinText); 
    793 //     char *info_geneText= XmTextGetString(m_info_GeneText); 
    794 // 
    795 //     // UPDATE RELATED WIDGET 
    796 //     if((widget == m_crosshairText) 
    797 //         && (hex2rgb(&r, &g, &b, crosshairText))) m_crosshairColorString= crosshairText; 
    798 // 
    799 //     else if((widget == m_unmarkedText) 
    800 //         && (hex2rgb(&r, &g, &b, unmarkedText))) m_unmarkedColorString= unmarkedText; 
    801 // 
    802 //     else if((widget == m_markedText) 
    803 //         && (hex2rgb(&r, &g, &b, markedText))) m_markedColorString= markedText; 
    804 // 
    805 //     else if((widget == m_selectedText) 
    806 //         && (hex2rgb(&r, &g, &b, selectedText))) m_selectedColorString= selectedText; 
    807 // 
    808 //     else if((widget == m_textText) 
    809 //              && (hex2rgb(&r, &g, &b, textText))) m_textColorString= textText; 
    810 // 
    811 //     else if(widget == m_ID_ProteinText) m_id_protein= id_proteinText; 
    812 //     else if(widget == m_ID_GeneText) m_id_gene= id_geneText; 
    813 //     else if(widget == m_info_ProteinText) m_info_protein= info_proteinText; 
    814 //     else if(widget == m_info_GeneText) m_info_gene= info_geneText; 
    815  
    816     // UPDATE THE COLORS 
    817     updateColors(); 
     695    char *colorString = XmTextGetString(widget); 
     696    if(hex2rgb(&r, &g, &b, colorString)) freeset(colorStringVar, colorString); 
     697    else free(colorString); 
     698} 
     699 
     700void configDialog::textChangedCallback(Widget widget) { 
     701    if      (widget == m_crosshairText)    setColorFromTextWidget(m_crosshairText, m_crosshairColorString); // CROSSHAIR TEXT-WIDGET CHANGED? 
     702    else if (widget == m_unmarkedText)     setColorFromTextWidget(m_unmarkedText,  m_unmarkedColorString);  // UNMARKED TEXT-WIDGET CHANGED? 
     703    else if (widget == m_markedText)       setColorFromTextWidget(m_markedText,    m_markedColorString);    // MARKED TEXT-WIDGET CHANGED? 
     704    else if (widget == m_selectedText)     setColorFromTextWidget(m_selectedText,  m_selectedColorString);  // SELECTED TEXT-WIDGET CHANGED? 
     705    else if (widget == m_textText)         setColorFromTextWidget(m_textText,      m_textColorString);      // INFOTEXT TEXT-WIDGET CHANGED? 
     706    else if (widget == m_ID_ProteinText)   freeset(m_id_protein,   XmTextGetString(m_ID_ProteinText));      // PROTEIN-ID TEXT-WIDGET CHANGED? 
     707    else if (widget == m_ID_GeneText)      freeset(m_id_gene,      XmTextGetString(m_ID_GeneText));         // GENE-ID TEXT-WIDGET CHANGED? 
     708    else if (widget == m_info_ProteinText) freeset(m_info_protein, XmTextGetString(m_info_ProteinText));    // PROTEIN-TEXT TEXT-WIDGET CHANGED? 
     709    else if (widget == m_info_GeneText)    freeset(m_info_gene,    XmTextGetString(m_info_GeneText));       // GENE-TEXT TEXT-WIDGET CHANGED? 
     710 
     711    updateColors(); // UPDATE THE COLORS 
    818712} 
    819713 
  • trunk/PGT/dialog.cxx

    r5648 r5725  
    304304static char *pixmapPath(const char *pixmapName) 
    305305{ 
    306     return GB_strdup(GB_path_in_ARBLIB("pixmaps/pgt", pixmapName)); 
     306    return nulldup(GB_path_in_ARBLIB("pixmaps/pgt", pixmapName)); 
    307307} 
    308308 
  • trunk/PGT/image_dialog.cxx

    r5309 r5725  
    16271627 
    16281628    // RESET SPOT COUNTER VALUES 
    1629     m_numSpots= 0; 
    1630     m_numMarkedSpots= 0; 
    1631     m_numSelectedSpots= 0; 
    1632     if(m_selectedSpotName) 
    1633     { 
    1634         free(m_selectedSpotName); 
    1635         m_selectedSpotName= NULL; 
    1636     } 
     1629    m_numSpots         = 0; 
     1630    m_numMarkedSpots   = 0; 
     1631    m_numSelectedSpots = 0; 
     1632    freeset(m_selectedSpotName, NULL); 
    16371633 
    16381634    // ITERATE THROUGH THE SPOTS 
  • trunk/PGT/import_dialog.cxx

    r3978 r5725  
    10931093    { 
    10941094        // CLEAR OLD HEADER, IF AVAILABLE 
    1095         if(header[i]) 
    1096         { 
    1097             free(header[i]); 
    1098             header[i]= NULL; 
    1099         } 
    1100  
    11011095        // CLEAN STRING FOR USAGE AS ARB KEY 
    1102         header[i]= GBS_string_2_key(cell[i]); 
     1096        freeset(header[i], GBS_string_2_key(cell[i])); 
    11031097    } 
    11041098 
  • trunk/PGT/main_dialog.cxx

    r3986 r5725  
    290290{ 
    291291    // GET AWAR CONTENT 
    292     char *species_AWAR=    get_species_AWAR(); 
    293     char *experiment_AWAR= get_experiment_AWAR(); 
    294     char *proteome_AWAR get_proteom_AWAR(); 
    295     char *protein_AWAR=    get_protein_AWAR(); 
     292    char *species_AWAR    = get_species_AWAR(); 
     293    char *experiment_AWAR = get_experiment_AWAR(); 
     294    char *proteome_AWAR   = get_proteom_AWAR(); 
     295    char *protein_AWAR    = get_protein_AWAR(); 
    296296 
    297297    // SET DEFAULT CONTENT IF AWAR IS EMPTY 
    298     if(!species_AWAR || strlen(species_AWAR) == 0) 
    299     { 
    300         if(species_AWAR) free(species_AWAR); 
    301         species_AWAR= strdup("no selected species"); 
    302     } 
    303     if(!experiment_AWAR || strlen(experiment_AWAR) == 0) 
    304     { 
    305         if(experiment_AWAR) free(experiment_AWAR); 
    306         experiment_AWAR= strdup("no selected experiment"); 
    307     } 
    308     if(!proteome_AWAR || strlen(proteome_AWAR) == 0) 
    309     { 
    310         if(proteome_AWAR) free(proteome_AWAR); 
    311         proteome_AWAR= strdup("no selected proteome"); 
    312     } 
    313     if(!protein_AWAR || strlen(protein_AWAR) == 0) 
    314     { 
    315         if(protein_AWAR) free(protein_AWAR); 
    316         protein_AWAR= strdup("no selected protein"); 
    317     } 
    318  
     298    if (!species_AWAR    || !species_AWAR[0])    freedup(species_AWAR,    "no selected species"); 
     299    if (!experiment_AWAR || !experiment_AWAR[0]) freedup(experiment_AWAR, "no selected experiment"); 
     300    if (!proteome_AWAR   || !proteome_AWAR[0])   freedup(proteome_AWAR,   "no selected proteome"); 
     301    if (!protein_AWAR    || !protein_AWAR[0])    freedup(protein_AWAR,    "no selected protein"); 
     302     
    319303    // SET TEXT FIELD ENTRIES 
    320304    XtVaSetValues(m_speciesText, XmNvalue, species_AWAR, NULL); 
  • trunk/PHYLO/PH_data.cxx

    r5689 r5725  
    1313    struct PHENTRY *phentry; 
    1414 
    15     free(use); 
    16     use = 0; 
    17     for(phentry=entries;phentry;phentry=phentry->next) 
    18     { free(phentry->name); 
     15    freeset(use, 0); 
     16    for (phentry=entries;phentry;phentry=phentry->next) { 
     17        free(phentry->name); 
    1918        free(phentry->full_name); 
    2019        free((char *) phentry); 
  • trunk/PHYLO/PH_main.cxx

    r5695 r5725  
    264264        strcpy(digit_appended+fname_len, "0"); 
    265265 
    266         free(fname); 
    267         fname = digit_appended; 
     266        freeset(fname, digit_appended); 
    268267    } 
    269268    GBDATA *gb_sai[3]; 
  • trunk/PRIMER_DESIGN/primer_design.cxx

    r5630 r5725  
    345345            gene_sequence[gene_length] = 0; 
    346346 
    347             free(sequence); 
    348             sequence   = gene_sequence; 
     347            freeset(sequence, gene_sequence); 
    349348            length     = gene_length; 
    350349            add_offset = gene_start; 
  • trunk/PROBE/PT_etc.cxx

    r5390 r5725  
    2323        psg.w_N_mismatches[i] = i; 
    2424} 
    25 void pt_export_error(PT_local *locs, const char *error) 
    26 { 
    27     if (locs->ls_error) free(locs->ls_error); 
    28     locs->ls_error = strdup(error); 
     25 
     26void pt_export_error(PT_local *locs, const char *error) { 
     27    freedup(locs->ls_error, error); 
    2928} 
    3029 
     
    218217 
    219218    char *result = not_found ? GBS_strclose(not_found) : 0; 
    220     if (error) { 
    221         free(result); 
    222         result = 0; 
    223     } 
     219    if (error) freeset(result, 0); 
    224220    return result; 
    225221} 
  • trunk/PROBE/PT_io.cxx

    r5660 r5725  
    149149        strcpy(buffer,data); 
    150150        buffer[len++] = '.'; 
    151         free(data); 
    152         data = buffer; 
     151        freeset(data, buffer); 
    153152    } 
    154153    *psize = len; 
  • trunk/PROBE/PT_match.cxx

    r5669 r5725  
    347347    PT_probematch *ml; 
    348348    char          *rev_pro; 
    349     if (locs->pm_sequence) free(locs->pm_sequence); 
    350     locs->pm_sequence       = psg.main_probe = strdup(probestring); 
     349 
     350    freedup(locs->pm_sequence, probestring); 
     351    psg.main_probe = locs->pm_sequence; 
     352 
    351353    compress_data(probestring); 
    352354    while ((ml = locs->pm)) destroy_PT_probematch(ml); 
     
    393395    psg.reversed = 0; 
    394396 
    395     if (locs->pm_sequence) free(locs->pm_sequence); 
    396     locs->pm_sequence = psg.main_probe = strdup(probestring); 
     397    freedup(locs->pm_sequence, probestring); 
     398    psg.main_probe = locs->pm_sequence; 
    397399 
    398400    psg.deep = locs->pm_max; 
     
    408410        rev_pro = reverse_probe(probestring,0); 
    409411        complement_probe(rev_pro,0 ); 
    410         if (locs->pm_csequence) free(locs->pm_csequence); 
    411         locs->pm_csequence = psg.main_probe = strdup(rev_pro); 
     412        freeset(locs->pm_csequence, psg.main_probe = strdup(rev_pro)); 
    412413        if (psg.deep >=0 ){ 
    413414            get_info_about_probe(locs, rev_pro, psg.pt, 0, 0.0, 0, 0); 
     
    586587 
    587588    static char *result = 0; 
    588     if (result) free(result); 
    589     result = GBS_strclose(memfile); 
    590  
     589    freeset(result, GBS_strclose(memfile)); 
    591590    return result; 
    592591} 
     
    626625 
    627626        static char *result = 0; 
    628         if (result) free(result); 
    629         result = GBS_strclose(memfile); 
     627        freeset(result, GBS_strclose(memfile)); 
    630628 
    631629        return result; 
  • trunk/PROBE_DESIGN/SaiProbeVisualization.hxx

    r4773 r5725  
    7777    void setHeadline(const char *hline) { 
    7878        sai_assert(hline); 
    79         free(headline); 
    80         headline = strdup(hline); 
     79        freedup(headline, hline); 
    8180    } 
    8281}; 
  • trunk/PROBE_DESIGN/probe_design.cxx

    r5660 r5725  
    15481548    GB_ERROR  error         = 0; 
    15491549 
    1550     if (mod_mode == TS_MOD_CLEAR) { 
    1551         target_string[0] = 0; 
    1552     } 
     1550    if (mod_mode == TS_MOD_CLEAR) target_string[0] = 0; 
    15531551    else { 
    15541552        GB_transaction dummy(GLOBAL_gb_main); 
     
    15621560            char T_or_U; 
    15631561            error = GBT_determine_T_or_U(ali_type, &T_or_U, "complement"); 
    1564             if (!error) { 
    1565                 char *new_target_string = GBT_complementNucSequence(target_string, strlen(target_string), T_or_U); 
    1566                 free(target_string); 
    1567                 target_string           = new_target_string; 
    1568             } 
    1569         } 
    1570     } 
    1571  
    1572     if (error) { 
    1573         aw_message(error); 
    1574     } 
    1575     else { 
    1576         root->awar(AWAR_TARGET_STRING)->write_string(target_string); 
    1577     } 
     1562            if (!error) freeset(target_string, GBT_complementNucSequence(target_string, strlen(target_string), T_or_U)); 
     1563        } 
     1564    } 
     1565 
     1566    if (error) aw_message(error); 
     1567    else root->awar(AWAR_TARGET_STRING)->write_string(target_string); 
    15781568    free(target_string); 
    15791569} 
     
    20762066    if (pg_global.pg_main) { 
    20772067        GB_close(pg_global.pg_main); 
    2078         free(pg_global.pg_filename); 
    2079  
    20802068        pg_global.pg_main = 0; 
    2081         pg_global.pg_filename = 0; 
     2069        freeset(pg_global.pg_filename, 0); 
    20822070    } 
    20832071 
     
    21442132    else { 
    21452133        error = GB_export_error("Can't open database '%s'", file_name); 
    2146         free(pg_global.pg_filename); 
    2147         pg_global.pg_filename = 0; 
     2134        freeset(pg_global.pg_filename, 0); 
    21482135    } 
    21492136 
     
    21902177// -------------------------------------------------------------------------------- 
    21912178AW_window *create_probe_group_result_window(AW_root *awr, AW_default cl_AW_canvas_ntw){ 
    2192     if (pg_global.awar_pg_result_filename) { 
    2193         free(pg_global.awar_pg_result_filename); 
    2194         pg_global.awar_pg_result_filename = 0; 
    2195     } 
    2196  
     2179    freeset(pg_global.awar_pg_result_filename, 0); 
    21972180    pg_global.ntw = (AWT_canvas*)cl_AW_canvas_ntw; 
    21982181 
  • trunk/PROBE_SERVER/PROBE_GROUP/pg_main.cxx

    r5675 r5725  
    303303            convert_commas_to_underscores(fullname); 
    304304        } 
    305         else { 
    306             error = GBS_global_string("no 'full_name' for species '%s'", node->name); 
    307         } 
     305        else error = GBS_global_string("no 'full_name' for species '%s'", node->name); 
    308306 
    309307        if (!error) { 
     
    313311                convert_commas_to_underscores(acc); 
    314312            } 
    315             else { 
    316                 error = GBS_global_string("no 'acc' for species '%s'", node->name); 
    317             } 
    318         } 
    319     } 
    320     else { 
    321         error = "Unlinked leaf node"; 
    322     } 
    323  
    324     if (!error) { 
    325         free(node->name); 
    326         node->name = encodeTreeNode(GBS_global_string("%i,%s,%s", id, fullname, acc)); 
    327     } 
     313            else error = GBS_global_string("no 'acc' for species '%s'", node->name); 
     314        } 
     315    } 
     316    else error = "Unlinked leaf node"; 
     317 
     318    if (!error) freeset(node->name, encodeTreeNode(GBS_global_string("%i,%s,%s", id, fullname, acc))); 
    328319 
    329320    free(acc); 
     
    844835static void unlinkTreeAndFreeNodeInfo(GBT_TREE *tree) { 
    845836    tree->gb_node = 0; 
    846     free(tree->name); 
    847     tree->name    = 0; 
     837    freeset(tree->name, 0); 
    848838 
    849839    if (!tree->is_leaf) { 
  • trunk/PROBE_SERVER/PROBE_GROUP/pg_search.cxx

    r5428 r5725  
    115115 
    116116    print("Search a free running pt-server.."); 
    117     current_server_name = GB_strdup(PG_probe_pt_look_for_server(gb_main, servername, error)); 
     117    current_server_name = nulldup(PG_probe_pt_look_for_server(gb_main, servername, error)); 
    118118    pg_assert(error || current_server_name); 
    119119    server_initialized  = true;; 
     
    125125//  ------------------------------------- 
    126126void PG_exit_pt_server(void) { 
    127     free(current_server_name); 
    128     current_server_name = 0; 
     127    freeset(current_server_name, 0); 
    129128    server_initialized  = false; 
    130129} 
     
    206205    if (ok) { 
    207206        static char *result; 
    208         if (result) { free(result); result = 0; } 
     207        freeset(result, 0); 
    209208 
    210209        ok = aisc_get(fpd.gl.link, PT_PEP, fpd.pep, PEP_RESULT, &result, NULL)==0; 
     
    252251 
    253252    static char *this_result; 
    254     if (this_result) { 
    255         free(this_result); 
    256         this_result = 0; 
    257     } 
     253    freeset(this_result, 0); 
    258254 
    259255    char *spunkt = strchr(result_ptr, ';'); 
     
    404400        if (!error && locs_error && locs_error[0]) { 
    405401            static char *err = 0; 
    406  
    407             if (err) free(err); 
    408             err        = locs_error; 
    409             locs_error = 0; 
    410  
     402            reassign(err, locs_error); 
    411403            error = err; 
    412404        } 
  • trunk/PROBE_SERVER/PROBE_GROUP_DESIGN/pgd_main.cxx

    r5356 r5725  
    181181        GLOBAL_out.put("Search a free running pt-server.."); 
    182182        indent i(GLOBAL_out); 
    183         current_server_name            = GB_strdup(PGD_probe_pt_look_for_server(gb_main,servername,error)); 
     183        current_server_name = nulldup(PGD_probe_pt_look_for_server(gb_main,servername,error)); 
    184184        if (!error) server_initialized = true; 
    185185    } 
     
    188188 
    189189static void PG_exit_pt_server(void) { 
    190     free(current_server_name); 
    191     current_server_name = 0; 
     190    freeset(current_server_name, 0); 
    192191    server_initialized  = false; 
    193192} 
     
    589588                else { 
    590589                    *acc++ = 0; 
    591  
    592                     char *newName2 = GBS_global_string_copy("n=%s,f=%s,a=%s", shortname.c_str(), fullname, acc); 
    593  
    594                     free(newName); 
    595                     newName = newName2; 
     590                    freeset(newName, GBS_global_string_copy("n=%s,f=%s,a=%s", shortname.c_str(), fullname, acc)); 
    596591                } 
    597592            } 
     
    603598        } 
    604599 
    605         free(node->name); 
    606         node->name = newName; 
     600        freeset(node->name, newName); 
    607601        return 0; 
    608602    } 
     
    611605    if (node->remark_branch) { // if remark_branch then it is a group name 
    612606        char *groupName = decodeTreeNode(node->remark_branch, error); 
     607        if (!error) { 
     608            freeset(node->remark_branch, 0); 
     609            freeset(node->name, GBS_global_string_copy("g=%s", groupName)); 
     610        } 
     611        free(groupName); 
     612         
    613613        if (error) return error; 
    614  
    615         char *newName = GBS_global_string_copy("g=%s", groupName); 
    616         free(groupName); 
    617  
    618         free(node->remark_branch); 
    619         node->remark_branch = 0; 
    620  
    621         free(node->name); 
    622         node->name = newName; 
    623614    } 
    624615 
     
    629620static GB_ERROR PGD_encodeBranchNames(GBT_TREE *node) { 
    630621    if (node->name) { // all nodes 
    631         char *newName = encodeTreeNode(node->name); 
    632         free(node->name); 
    633         node->name    = newName; 
     622        freeset(node->name, encodeTreeNode(node->name)); 
    634623    } 
    635624 
  • trunk/SECEDIT/SEC_abspos.cxx

    r5675 r5725  
    1818 
    1919void XString::set_length(size_t len) { 
    20     if (number_found && x_string_len<len) { 
    21         free(number_found); 
    22         number_found = 0; 
    23     } 
     20    if (number_found && x_string_len<len) freeset(number_found, 0); 
    2421    x_string_len = len; 
    2522    initialized  = false; 
     
    7370 
    7471        if (abspos) { // re-initialization 
    75             if (x_count<x) { // abspos array too small 
    76                 free(abspos); 
    77                 abspos = 0; 
    78             } 
     72            if (x_count<x) freeset(abspos, 0); // abspos array too small 
    7973        } 
    8074        x_count = x; 
     
    135129    size_t bufsize = x_string_len+1;  
    136130 
    137     if (copy && copy_alloc<bufsize) { 
    138         free(copy); 
    139         copy = 0; 
    140     } 
    141  
    142     if (!copy) { 
    143         copy       = (char*)malloc(bufsize); 
     131    if (!copy || copy_alloc<bufsize) { 
     132        freeset(copy, (char*)malloc(bufsize)); 
    144133        copy_alloc = bufsize; 
    145134    } 
  • trunk/SECEDIT/SEC_graphic.cxx

    r5675 r5725  
    686686        request_update(SEC_UPDATE_RECOUNT); 
    687687        if (load_error) { // previous load error? 
    688             free(load_error); 
    689             load_error = 0; 
     688            freeset(load_error, 0); 
    690689            request_update(SEC_UPDATE_ZOOM_RESET); 
    691690        } 
  • trunk/SECEDIT/SEC_paint.cxx

    r5183 r5725  
    363363#warning move to SEC_db_interface 
    364364void SEC_root::cacheBackgroundColor() { 
    365     free(bg_color); 
    366     bg_color = 0; 
     365    freeset(bg_color, 0); 
    367366 
    368367    const ED4_sequence_terminal *sterm = db->get_seqTerminal(); 
  • trunk/SERVERCNTRL/servercntrl.c

    r5574 r5725  
    307307 
    308308    erg             = (struct arb_params *)calloc(sizeof(struct arb_params),1); 
    309     erg->db_server  = GB_strdup(":"); 
    310     erg->job_server = GB_strdup("ARB_JOB_SERVER"); 
    311     erg->mgr_server = GB_strdup("ARB_MGR_SERVER"); 
    312     erg->pt_server  = GB_strdup("ARB_PT_SERVER"); 
     309    erg->db_server  = strdup(":"); 
     310    erg->job_server = strdup("ARB_JOB_SERVER"); 
     311    erg->mgr_server = strdup("ARB_MGR_SERVER"); 
     312    erg->pt_server  = strdup("ARB_PT_SERVER"); 
    313313 
    314314    for (s=d=0; s<*argc; s++) { 
  • trunk/SL/AW_NAME/AW_names_admin.cxx

    r5648 r5725  
    1212    const char *field    = AW_get_nameserver_addid((GBDATA*)cl_gb_main); 
    1313    const char *filename = field[0] ? GBS_global_string("names_%s.dat", field) : "names_dat"; 
    14     char       *fullname = GB_strdup(GB_path_in_ARBLIB("nas", filename)); 
     14    char       *fullname = nulldup(GB_path_in_ARBLIB("nas", filename)); 
    1515 
    1616    return fullname; 
  • trunk/SL/AW_NAME/AW_rename.cxx

    r5676 r5725  
    8282                for (int c = 0; c<serverCount; c++) { 
    8383                    const char *ipport = GBS_read_arb_tcp(nameservers[c]); 
    84                     fieldNames[c]      = GB_strdup(GBS_scan_arb_tcp_param(ipport, "-f")); // may return 0 
     84                    fieldNames[c]      = nulldup(GBS_scan_arb_tcp_param(ipport, "-f")); // may return 0 
    8585                } 
    8686 
     
    533533                if (!err) { 
    534534                    char *newshrt = AWTC_create_numbered_suffix(hash, shrt, warning); 
    535                     if (newshrt) { 
    536                         free(shrt); 
    537                         shrt = newshrt; 
    538                     } 
     535                    if (newshrt) freeset(shrt, newshrt); 
    539536 
    540537                    GBS_incr_hash(hash,shrt); 
  • trunk/SL/HELIX/BI_helix.hxx

    r4963 r5725  
    8181 
    8282    static char *get_error() { return helix_error; } 
    83     static void clear_error() { free(helix_error); helix_error = 0; } 
    84     static void set_error(const char *err) { free(helix_error); helix_error = err ? strdup(err) : 0; } 
     83    static void clear_error() { freeset(helix_error, NULL); } 
     84    static void set_error(const char *err) { freedup(helix_error, err); } 
    8585 
    8686    BI_helix(void); 
  • trunk/TOOLS/arb_export_rates.cxx

    r5034 r5725  
    103103 
    104104                    if (APPEARS_IN_HEADER(command_char)) { 
    105                         char *neu = GB_strdup(GBS_global_string("%s %c", firstline, command_char)); 
    106                         free(firstline); 
    107                         firstline = neu; 
     105                        freeset(firstline, GBS_global_string_copy("%s %c", firstline, command_char)); 
    108106                    } 
    109107                } 
     
    180178                seq_len = ali_len; 
    181179 
    182                 free(weight[int('1')]); 
    183                 weight[int('1')] = strdup(" 1"); 
     180                freedup(weight[int('1')], " 1"); 
    184181            } 
    185182 
  • trunk/TOOLS/arb_gene_probe.cxx

    r5660 r5725  
    341341                next_split_pos_list = GBS_global_string_copy("%s,%i", split_pos_list, genome_pos); 
    342342            } 
    343             free(split_pos_list); 
    344             split_pos_list = next_split_pos_list; 
     343            freeset(split_pos_list, next_split_pos_list); 
    345344        } 
    346345    } 
  • trunk/TOOLS/arb_proto_2_xsub.cxx

    r5636 r5725  
    7272 
    7373    for (tok = strtok(data,";\n");tok;tok = strtok(0,";\n")) { 
    74         if (type) { free(type); type = 0; } 
     74        freeset(type, 0); 
    7575 
    7676#if defined(DEBUG) 
     
    170170        /* check type */ 
    171171        GB_BOOL const_char = GB_FALSE; 
    172         GB_BOOL free_flag = GB_FALSE; 
    173         if (!strcmp(type,"char*"))     const_char = GB_TRUE; 
    174         if (!strncmp(type,"schar",5)){ 
    175             free_flag     = GB_TRUE; 
    176             char *newtype = strdup(type+1); 
    177             free(type); 
    178             type          = newtype; 
    179         } 
    180  
    181         if (!strcmp(type,"float")) { 
    182             free(type); 
    183             type = strdup("double"); 
    184         } 
    185         if (!strcmp(type,"GB_alignment_type")) { 
    186             free(type); 
    187             type = strdup("double"); 
    188         } 
     172        GB_BOOL free_flag  = GB_FALSE; 
     173 
     174        if (strcmp(type,"char*") == 0) const_char = GB_TRUE; 
     175        if (strncmp(type,"schar",5) == 0) { 
     176            free_flag = GB_TRUE; 
     177            freedup(type, type+1); 
     178        } 
     179 
     180        if (strcmp(type,"float")             == 0) freedup(type, "double"); 
     181        if (strcmp(type,"GB_alignment_type") == 0) freedup(type, "double"); 
    189182 
    190183        tok = sp; 
  • trunk/TOOLS/arb_read_tree.cxx

    r5350 r5725  
    2020void add_bootstrap(GBT_TREE *node, double hundred) { 
    2121    if (node->is_leaf) { 
    22         if (node->remark_branch) { 
    23             free(node->remark_branch); 
    24             node->remark_branch = 0; 
    25         } 
     22        freeset(node->remark_branch, 0); 
    2623        return; 
    2724    } 
  • trunk/TRS/tree_lib.cxx

    r5390 r5725  
    4444    vsprintf(p,templat,parg); 
    4545 
    46     if (TRS_error_buffer) free(TRS_error_buffer); 
    47     TRS_error_buffer = strdup(buffer); 
     46    freedup(TRS_error_buffer, buffer); 
    4847    return TRS_error_buffer; 
    4948} 
  • trunk/WINDOW/AW_at.cxx

    r5202 r5725  
    117117 
    118118void AW_window::label( const char *Label ) { 
    119     free(_at->label_for_inputfield); 
    120     _at->label_for_inputfield = strdup(Label); 
     119    freedup(_at->label_for_inputfield, Label); 
    121120} 
    122121 
     
    317316    _at->highlight             = AW_FALSE; 
    318317 
    319     free(_at->id_for_next_button)      ; _at->id_for_next_button       = 0; 
    320     free(_at->helptext_for_next_button); _at->helptext_for_next_button = 0; 
    321     free(_at->label_for_inputfield)    ; _at->label_for_inputfield     = 0; 
     318    freeset(_at->id_for_next_button, 0); 
     319    freeset(_at->helptext_for_next_button, 0); 
     320    freeset(_at->label_for_inputfield, 0); 
    322321     
    323322    _at->background_color = 0; 
  • trunk/WINDOW/AW_button.cxx

    r5648 r5725  
    326326 
    327327static char *pixmapPath(const char *pixmapName) { 
    328     return GB_strdup(GB_path_in_ARBLIB("pixmaps", pixmapName)); 
     328    return nulldup(GB_path_in_ARBLIB("pixmaps", pixmapName)); 
    329329} 
    330330 
     
    894894    aw_toggle_data *tdata  = new aw_toggle_data; 
    895895    tdata->isTextToggle    = true; 
    896     tdata->bitmapOrText[0] = GB_strdup(noText); 
    897     tdata->bitmapOrText[1] = GB_strdup(yesText); 
     896    tdata->bitmapOrText[0] = strdup(noText); 
     897    tdata->bitmapOrText[1] = strdup(yesText); 
    898898    tdata->buttonWidth     = buttonWidth; 
    899899 
     
    14201420void AW_window::set_list_entry_char_value(const char *new_char_value) { 
    14211421    if (!current_list_table) AW_ERROR("No Selection List Iterator"); 
    1422  
    1423     free(current_list_table->char_value); 
    1424     current_list_table->char_value = AW_select_table_struct::copy_string(new_char_value); 
     1422    freeset(current_list_table->char_value, AW_select_table_struct::copy_string(new_char_value)); 
    14251423} 
    14261424 
    14271425void AW_window::set_list_entry_displayed(const char *new_displayed) { 
    14281426    if (!current_list_table) AW_ERROR("No Selection List Iterator"); 
    1429  
    1430     free(current_list_table->displayed); 
    1431     current_list_table->displayed = AW_select_table_struct::copy_string(new_displayed); 
     1427    freeset(current_list_table->displayed, AW_select_table_struct::copy_string(new_displayed)); 
    14321428} 
    14331429 
  • trunk/WINDOW/AW_nawar.cxx

    r5483 r5725  
    7272 
    7373void AW_awar::get( char **p_string ) { 
    74     free(*p_string); 
    75     *p_string = read_string(); 
     74    freeset(*p_string, read_string()); 
    7675} 
    7776 
     
    601600    if (strcmp(awar_name, new_awar) != 0) { 
    602601        remove_callback(); 
    603         free(awar_name); 
    604         awar_name = strdup(new_awar); 
     602        freedup(awar_name, new_awar); 
    605603        add_callback(); 
    606604    } 
  • trunk/WINDOW/AW_preset.cxx

    r5309 r5725  
    182182    } 
    183183    awr->awar(AWAR_GLOBAL_COLOR_NAME)->write_string(label_name); 
    184     free(aw_glob_font_awar_name); 
    185     aw_glob_font_awar_name = strdup(awar_name); 
     184    freedup(aw_glob_font_awar_name, awar_name); 
    186185    aws->show(); 
    187186} 
     
    690689                } 
    691690 
    692                 free(id_copy); id_copy = 0; 
     691                freeset(id_copy, 0); 
    693692            } 
    694693 
  • trunk/WINDOW/AW_question.cxx

    r5708 r5725  
    2424 
    2525void AW_repeated_question::add_help(const char *help_file) { 
    26     if (helpfile) { 
    27         free(helpfile); 
    28         helpfile = 0; 
    29     } 
    30     if (help_file) { 
    31         helpfile = strdup(help_file); 
    32     } 
     26    freedup(helpfile, help_file); 
    3327} 
    3428 
  • trunk/WINDOW/AW_status.cxx

    r5711 r5725  
    631631                fprintf(stderr, "received AW_STATUS_CMD_GAUGE\n"); fflush(stdout); 
    632632#endif // TRACE_STATUS 
    633                 free(gauge); 
    634                 gauge = str; 
    635                 str   = 0; 
     633 
     634                reassign(gauge, str); 
    636635 
    637636                if (gaugeValue>0) { 
     
    694693    int i; 
    695694    AW_root *awr = aww->get_root(); 
    696     for (i = 0; i< AW_MESSAGE_LINES; i++){ 
    697         free(aw_stg.lines[i]); 
    698         aw_stg.lines[i] = 0; 
    699     }; 
     695    for (i = 0; i< AW_MESSAGE_LINES; i++) freeset(aw_stg.lines[i], 0); 
    700696    awr->awar(AWAR_ERROR_MESSAGES)->write_string("" ); 
    701697} 
     
    953949 
    954950    if (button_list[0] == 0) { 
    955         // aw_assert(0);           // empty button_list 
    956         free(button_list); 
    957         button_list = strdup("Maybe ok,EXIT"); 
    958         msg         = GBS_global_string_copy("%s\n(Program error - Unsure what happens when you click ok)", msg); 
     951        freedup(button_list, "Maybe ok,EXIT"); 
     952        GBK_dump_backtrace(stderr, "Empty buttonlist"); 
     953        msg = GBS_global_string_copy("%s\n" 
     954                                     "(Program error - Unsure what happens when you click ok\n" 
     955                                     " Check console for backtrace and report error)", 
     956                                     msg); 
    959957    } 
    960958 
     
    11511149            break; 
    11521150        case MAKE_DEFAULT: 
    1153             free(content); 
    1154             content    = strdup(Default); 
     1151            freedup(content, Default); 
    11551152            break; 
    11561153        case MAKE_UNKNOWN: 
     
    13241321 
    13251322        if (buttons)  { 
    1326             char *but    = GB_strdup(buttons); 
     1323            char *but    = strdup(buttons); 
    13271324            char *word; 
    13281325            int   result = 0; 
     
    13581355    aw_msg->clear_selection_list(sel); 
    13591356    { 
    1360         char *values = GB_strdup(value_list); 
     1357        char *values = strdup(value_list); 
    13611358        char *word; 
    13621359 
     
    13921389                } 
    13931390            } 
    1394             free(last_input); 
    1395             last_input = this_input; 
    1396             this_input = 0; 
     1391            reassign(last_input, this_input); 
    13971392        } 
    13981393        free(this_input); 
     
    15001495    GB_CSTR   result             = 0; 
    15011496    char     *user_doc_path      = strdup(GB_getenvDOCPATH()); 
    1502     char     *devel_doc_path     = GB_strdup(GB_path_in_ARBHOME("HELP_SOURCE/oldhelp", NULL)); 
     1497    char     *devel_doc_path     = strdup(GB_path_in_ARBHOME("HELP_SOURCE/oldhelp", NULL)); 
    15031498    size_t    user_doc_path_len  = strlen(user_doc_path); 
    15041499    size_t    devel_doc_path_len = strlen(devel_doc_path); 
     
    15221517            if (path_for_edit) { 
    15231518#if defined(DEBUG) 
    1524                 char *gen_doc_path = GB_strdup(GB_path_in_ARBHOME("HELP_SOURCE/genhelp", NULL)); 
     1519                char *gen_doc_path = strdup(GB_path_in_ARBHOME("HELP_SOURCE/genhelp", NULL)); 
    15251520 
    15261521                char *devel_source = GBS_global_string_copy("%s/%s", devel_doc_path, rel_path); 
     
    15851580        } 
    15861581        else { 
    1587             free(result); 
    1588             result = 0; 
     1582            freeset(result, 0); 
    15891583            GB_export_error("Can't browse that file type."); 
    15901584        } 
     
    16381632    if (file) { 
    16391633        result = GBS_string_eval(file,"*\nTITLE*\n*=*2:\t=",0); 
    1640         if (strcmp(file, result)==0) { 
    1641             free(result); 
    1642             result = 0; 
    1643         } 
     1634        if (strcmp(file, result)==0) freeset(result, 0); 
    16441635        free(file); 
    16451636    } 
     
    16681659        const char *sep = strchr(history, '#'); 
    16691660        if (sep) { 
    1670             char *first   = GB_strpartdup(history, sep-1); 
    1671             char *newhist = GBS_global_string_copy("%s#%s", sep+1, first); // wrap first to end 
    1672  
    1673             free(aw_help_global.history); 
    1674             aw_help_global.history = newhist; 
    1675  
     1661            char *first = GB_strpartdup(history, sep-1); 
     1662             
     1663            freeset(aw_help_global.history, GBS_global_string_copy("%s#%s", sep+1, first)); // wrap first to end 
    16761664            free(first); 
    1677              
    16781665            aw_help_select_newest_in_history(aw_root); 
    16791666        } 
     
    17551742 
    17561743                aw_assert(h); 
    1757  
    1758                 free(aw_help_global.history); 
    1759                 aw_help_global.history = h; 
    1760  
     1744                freeset(aw_help_global.history, h); 
    17611745                free(comm); 
    17621746            } 
     
    18341818    char     *searchtext = aww->get_root()->awar("tmp/aw_window/search_expression")->read_string(); 
    18351819 
    1836     if (searchtext[0]==0) { 
    1837         error = "Empty searchstring"; 
    1838     } 
     1820    if (searchtext[0]==0) error = "Empty searchstring"; 
    18391821    else { 
    18401822        char        *helpfilename = 0; 
     
    18421824 
    18431825        // replace all spaces in 'searchtext' by '.*' 
    1844         { 
    1845             char *searchtext2 = GBS_string_eval(searchtext, " =.*", 0);  
    1846             if (searchtext2) { 
    1847                 free(searchtext); 
    1848                 searchtext = searchtext2; 
    1849             } 
    1850         } 
     1826        freeset(searchtext, GBS_string_eval(searchtext, " =.*", 0)); 
    18511827 
    18521828        // grep .hlp for occurances of 'searchtext'. 
     
    19071883                    else            fprintf(helpfp, "\t\tThere are no results.\n"); 
    19081884 
    1909                     if (results>0) { 
    1910                         if (last_help) free(last_help); 
    1911                         last_help = strdup(helpfilename); 
    1912                     } 
     1885                    if (results>0) freedup(last_help, helpfilename); 
    19131886 
    19141887                    fclose(helpfp); 
  • trunk/WINDOW/AW_window.cxx

    r5673 r5725  
    271271} 
    272272 
    273 AW_select_table_struct::AW_select_table_struct(const char *displayedi, 
    274         const char *valuei) { 
     273AW_select_table_struct::AW_select_table_struct(const char *displayedi, const char *valuei) { 
    275274    memset((char *)this, 0, sizeof(AW_select_table_struct)); 
    276275    displayed = copy_string(displayedi); 
    277276    char_value = strdup(valuei); 
    278277} 
    279 AW_select_table_struct::AW_select_table_struct(const char *displayedi, 
    280         long valuei) { 
     278AW_select_table_struct::AW_select_table_struct(const char *displayedi, long valuei) { 
    281279    memset((char *)this, 0, sizeof(AW_select_table_struct)); 
    282280    displayed = copy_string(displayedi); 
    283281    int_value = valuei;; 
    284282} 
    285 AW_select_table_struct::AW_select_table_struct(const char *displayedi, 
    286         float valuei) { 
     283AW_select_table_struct::AW_select_table_struct(const char *displayedi, float valuei) { 
    287284    memset((char *)this, 0, sizeof(AW_select_table_struct)); 
    288285    displayed = copy_string(displayedi); 
     
    294291} 
    295292 
    296 AW_selection_list::AW_selection_list(const char *variable_namei, 
    297         int variable_typei, Widget select_list_widgeti) { 
     293AW_selection_list::AW_selection_list(const char *variable_namei, int variable_typei, Widget select_list_widgeti) { 
    298294    memset((char *)this, 0, sizeof(AW_selection_list)); 
    299     variable_name = GB_strdup(variable_namei); 
     295    variable_name = nulldup(variable_namei); 
    300296    variable_type = (AW_VARIABLE_TYPE)variable_typei; 
    301297    select_list_widget = select_list_widgeti; 
     
    347343    aw_assert(win_name); 
    348344 
    349     free(window_name); window_name = strdup(win_name); 
    350     free(sub_menu); sub_menu = 0; 
     345    freedup(window_name, win_name); 
     346    freeset(sub_menu, 0); 
    351347 
    352348    printf("---------------------------------------- list of menus for '%s'\n", window_name); 
     
    368364    dumpMenuEntry(sub_name); // dump the menu itself 
    369365 
    370     if (sub_menu) { 
    371         char *new_sub_menu = strdup(GBS_global_string("%s/%s", sub_menu, sub_name)); 
    372         free(sub_menu); 
    373         sub_menu = new_sub_menu; 
    374     } 
    375     else { 
    376         sub_menu = strdup(sub_name); 
    377     } 
     366    if (sub_menu) freeset(sub_menu, GBS_global_string_copy("%s/%s", sub_menu, sub_name)); 
     367    else sub_menu = strdup(sub_name); 
    378368} 
    379369 
     
    384374        lslash[0] = 0; 
    385375    } 
    386     else { 
    387         free(sub_menu); sub_menu = 0; 
    388     } 
     376    else freeset(sub_menu, 0); 
    389377} 
    390378 
    391379static void dumpCloseAllSubMenus() { 
    392     free(sub_menu); sub_menu = 0; 
     380    freeset(sub_menu, 0); 
    393381} 
    394382 
     
    27462734    static char *unused; 
    27472735 
    2748     if (unused) 
    2749         free(unused); 
    2750     unused = strdup(topic_name); 
     2736    freedup(unused, topic_name); 
    27512737 
    27522738    for (t = 0; unused[t]; ++t) { 
     
    28362822} 
    28372823 
    2838 static void open_test_duplicate_mnemonics(int menu_deep, 
    2839         const char *sub_menu_name, const char *mnemonic) { 
     2824static void open_test_duplicate_mnemonics(int menu_deep, const char *sub_menu_name, const char *mnemonic) { 
    28402825    aw_assert(menu_deep == menu_deep_check+1); 
    28412826    menu_deep_check = menu_deep; 
     
    28452830 
    28462831    memset(buf, 0, len); 
    2847  
    28482832    sprintf(buf, "%s|%s", TD_menu_name, sub_menu_name); 
    28492833 
    28502834    test_duplicate_mnemonics(menu_deep-1, sub_menu_name, mnemonic); 
    28512835 
    2852     free(TD_menu_name); 
    2853     TD_menu_name = buf; 
    2854  
     2836    freeset(TD_menu_name, buf); 
    28552837    TD_poss[menu_deep] = 0; 
    28562838} 
     
    28772859    int i; 
    28782860 
    2879     if (TD_menu_name) { 
    2880         close_test_duplicate_mnemonics(1); // close last menu 
    2881         free(TD_menu_name); 
    2882         TD_menu_name = 0; 
    2883     } 
    2884  
    2885     TD_menu_name = strdup(""); 
     2861    if (TD_menu_name) close_test_duplicate_mnemonics(1); // close last menu 
     2862    freedup(TD_menu_name, ""); 
    28862863 
    28872864    for (i=0; i<MAX_DEEP_TO_TEST; i++) { 
     
    28932870    close_test_duplicate_mnemonics(1); // close last menu 
    28942871    aw_assert(TD_menu_name); 
    2895     free(TD_menu_name); 
    2896     TD_menu_name = 0; 
     2872    freeset(TD_menu_name, 0); 
    28972873    aw_assert(menu_deep_check == 0); 
    28982874} 
     
    32563232void AW_window::set_window_title(const char *title) { 
    32573233    XtVaSetValues(p_w->shell, XmNtitle, title, NULL); 
    3258     free(window_name); 
    3259     window_name = strdup(title); 
     3234    freedup(window_name, title); 
    32603235} 
    32613236 
     
    34603435    prvt->recording_macro_file = 0; 
    34613436 
    3462     free(prvt->recording_macro_path); 
    3463     free(prvt->stop_action_name); 
    3464     free(prvt->application_name_for_macros); 
    3465  
    3466     prvt->recording_macro_path = 0; 
    3467     prvt->stop_action_name = 0; 
    3468     prvt->application_name_for_macros = 0; 
     3437    freeset(prvt->recording_macro_path, 0); 
     3438    freeset(prvt->stop_action_name, 0); 
     3439    freeset(prvt->application_name_for_macros, 0); 
    34693440 
    34703441    return 0; 
  • trunk/WINDOW/AW_xfont.cxx

    r5507 r5725  
    529529                fprintf(stderr, "ARB fontpackage: Unexpectedly couldn't load font '%s', falling back to '%s' (f=%i, s=%i)\n", nf->fname, NORMAL_FONT, f, s); 
    530530                fontst = XLoadQueryFont(tool_d, NORMAL_FONT); // @@@ may return 0! 
    531                 free(nf->fname); 
    532                 nf->fname = strdup(NORMAL_FONT);    /* store actual name */ 
     531                freedup(nf->fname, NORMAL_FONT);    /* store actual name */ 
    533532            } 
    534533            /* put the structure in the list */ 
  • trunk/ptpan/PT_buildtree.cxx

    r5716 r5725  
    9595 
    9696  /* return some memory not used anymore */ 
    97   free(pp->pp_StdSfxNodes); 
    98   pp->pp_StdSfxNodes = NULL; 
     97  freeset(pp->pp_StdSfxNodes, NULL); 
    9998 
    10099  if(GB_rename_file(newtreename, pg->pg_IndexName)) 
     
    10251024 
    10261025  /* return some memory not used anymore */ 
    1027   free(pp->pp_SfxNodes); 
    1028   free(pp->pp_BranchCode); 
    1029   free(pp->pp_ShortEdgeCode); 
    1030   free(pp->pp_LongEdgeLenCode); 
    1031   free(pp->pp_LongDictRaw); 
    1032   free(pp->pp_LeafBuffer); 
    1033   pp->pp_SfxNodes = NULL; 
    1034   pp->pp_LevelStats = NULL; 
    1035   pp->pp_BranchCode = NULL; 
    1036   pp->pp_ShortEdgeCode = NULL; 
    1037   pp->pp_LongEdgeLenCode = NULL; 
    1038   pp->pp_LongDictRaw = NULL; 
    1039   pp->pp_LeafBuffer = NULL; 
     1026  freeset(pp->pp_SfxNodes, NULL); 
     1027  freeset(pp->pp_BranchCode, NULL); 
     1028  freeset(pp->pp_ShortEdgeCode, NULL); 
     1029  freeset(pp->pp_LongEdgeLenCode, NULL); 
     1030  freeset(pp->pp_LongDictRaw, NULL); 
     1031  freeset(pp->pp_LeafBuffer, NULL); 
     1032 
     1033  pp->pp_LevelStats     = NULL; 
    10401034  pp->pp_LeafBufferSize = 0; 
     1035 
    10411036  return(TRUE); 
    10421037} 
     
    11861181 
    11871182  /* free some memory not required anymore */ 
    1188   free(pp->pp_QuickPrefixLookup); 
    1189   pp->pp_QuickPrefixLookup = NULL; 
     1183  freeset(pp->pp_QuickPrefixLookup, NULL); 
    11901184 
    11911185  printf("Quick Prefix Lookup speedup: %ld%% (%ld)\n", 
     
    17101704    pp->pp_TreePruneLength); 
    17111705 
    1712   free(pp->pp_LevelStats); 
    1713   pp->pp_LevelStats = NULL; 
     1706  freeset(pp->pp_LevelStats, NULL); 
    17141707 
    17151708  /* allocate branch histogram */ 
  • trunk/ptpan/PT_cachehandler.cxx

    r5566 r5725  
    3535  { 
    3636    Remove(&cn->cn_Node); 
    37     free(cn); 
    38     cn = (struct CacheNode *) ch->ch_UsedNodes.lh_Head; 
     37    freeset(cn, (struct CacheNode *) ch->ch_UsedNodes.lh_Head); 
    3938  } 
    4039  /* free memory in free node cache */ 
     
    4342  { 
    4443    Remove(&cn->cn_Node); 
    45     free(cn); 
    46     cn = (struct CacheNode *) ch->ch_FreeNodes.lh_Head; 
     44    freeset(cn, (struct CacheNode *) ch->ch_FreeNodes.lh_Head); 
    4745  } 
    4846  /* free structure itself */ 
  • trunk/ptpan/PT_etc.cxx

    r5566 r5725  
    5959  printf("EXTERN: PT_unknown_names\n"); 
    6060  /* free old string and allocate minimum buffer */ 
    61   free(pg->pg_UnknownSpecies.data); 
    62   pg->pg_UnknownSpecies.data = (STRPTR) malloc(allocsize); 
     61  freeset(pg->pg_UnknownSpecies.data, (STRPTR) malloc(allocsize)); 
    6362  *pg->pg_UnknownSpecies.data = 0; 
    6463  namestart = specnames = pdc->names.data; 
  • trunk/ptpan/PT_findEx.cxx

    r5566 r5725  
    3333 
    3434  /* free old result */ 
    35   if(pep->result) 
    36   { 
    37     free(pep->result); 
    38     pep->result = NULL; 
    39   } 
     35  freeset(pep->result, NULL); 
    4036 
    4137  /* do we need to start from scratch? */ 
     
    105101        parenttn = tn->tn_Parent; 
    106102        seqcode = tn->tn_ParentSeq + 1; 
    107         free(tn); 
    108         tn = parenttn; 
     103        freeset(tn, parenttn); 
    109104        if(!tn) 
    110105        { 
     
    150145    parenttn = tn->tn_Parent; 
    151146    seqcode = tn->tn_ParentSeq + 1; 
    152     free(tn); 
    153     tn = parenttn; 
     147    freeset(tn, parenttn); 
    154148  } 
    155149  *outptr = 0; 
  • trunk/ptpan/PT_hashing.cxx

    r5566 r5725  
    2222      return(ha); 
    2323    } 
    24     free(ha); 
    25     ha = NULL; 
     24    freeset(ha, NULL); 
    2625  } 
    2726  return(ha); 
  • trunk/ptpan/PT_io.cxx

    r5719 r5725  
    697697 
    698698  /* free memory if previously allocated */ 
    699   if(pg->pg_EcoliSeq) 
    700   { 
    701     free(pg->pg_EcoliSeq); 
    702     pg->pg_EcoliSeq = NULL; 
    703   } 
    704   if(pg->pg_EcoliBaseTable) 
    705   { 
    706     free(pg->pg_EcoliBaseTable); 
    707     pg->pg_EcoliBaseTable = NULL; 
    708   } 
     699  freeset(pg->pg_EcoliSeq, NULL); 
     700  freeset(pg->pg_EcoliBaseTable, NULL); 
    709701 
    710702  /* prepare ecoli sequence */ 
     
    760752    free(ps->ps_Name); 
    761753    free(ps->ps_FullName); 
    762     free(ps); 
    763     ps = (struct PTPanSpecies *) pg->pg_Species.lh_Head; 
     754    freeset(ps, (struct PTPanSpecies *) pg->pg_Species.lh_Head); 
    764755  } 
    765756  FreeBinTree(pg->pg_SpeciesBinTree); 
     
    796787  { 
    797788    /* load alignment data */ 
    798     free(ps->ps_SeqData); 
    799     ps->ps_SeqData = NULL; 
     789    freeset(ps->ps_SeqData, NULL); 
    800790    return(TRUE); 
    801791  } 
     
    942932 
    943933    ps->ps_RawDataSize = CompressSequenceWithDotsAndHyphens(pg, ps); 
    944     free(ps->ps_SeqData); 
    945     ps->ps_SeqData = NULL; 
     934    freeset(ps->ps_SeqData, NULL); 
    946935    if (ps->ps_RawDataSize < 0)                                 // TODO: problem, ps_RawDataSize is unsigned... 
    947936    { 
     
    10801069  // read Ecoli Sequence 
    10811070  /* free memory if previously allocated */ 
    1082   if(pg->pg_EcoliSeq) 
    1083   { 
    1084     free(pg->pg_EcoliSeq); 
    1085     pg->pg_EcoliSeq = NULL; 
    1086   } 
    1087   if(pg->pg_EcoliBaseTable) 
    1088   { 
    1089     free(pg->pg_EcoliBaseTable); 
    1090     pg->pg_EcoliBaseTable = NULL; 
    1091   } 
     1071  freeset(pg->pg_EcoliSeq, NULL); 
     1072  freeset(pg->pg_EcoliBaseTable, NULL); 
    10921073 
    10931074  fread(&pg->pg_EcoliSeqSize, sizeof(pg->pg_EcoliSeqSize), 1, fh); 
     
    12991280    FreeHuffmanTree(pp->pp_ShortEdgeTree); 
    13001281    FreeHuffmanTree(pp->pp_LongEdgeLenTree); 
    1301     free(pp); 
    1302     pp = (struct PTPanPartition *) pg->pg_Partitions.lh_Head; 
     1282    freeset(pp, (struct PTPanPartition *) pg->pg_Partitions.lh_Head); 
    13031283  } 
    13041284  pg->pg_NumPartitions = 0; 
  • trunk/ptpan/PT_new_design.cxx

    r5687 r5725  
    373373            parenttn = tn->tn_Parent; 
    374374            seqcode = tn->tn_ParentSeq + 1; 
    375             free(tn); 
    376             tn = parenttn; 
     375            freeset(tn, parenttn); 
    377376        } 
    378377    } while (! done); 
     
    789788                parenttn = tn->tn_Parent; 
    790789                seqcode  = tn->tn_ParentSeq + 1; 
    791                 free(tn); 
    792                 tn = parenttn; 
     790                freeset(tn, parenttn); 
    793791                if (! tn) 
    794792                { 
     
    839837        parenttn = tn->tn_Parent; 
    840838        seqcode  = tn->tn_ParentSeq + 1; 
    841         free(tn); 
    842         tn = parenttn; 
     839        freeset(tn, parenttn); 
    843840    } while (TRUE); 
    844841 
  • trunk/ptpan/PT_treepack.cxx

    r5721 r5725  
    220220      } 
    221221    } 
    222     free(pp->pp_LongDictRaw); 
    223     pp->pp_LongDictRaw = NULL; 
     222    freeset(pp->pp_LongDictRaw, NULL); 
    224223  } else { 
    225224    printf("Out of memory while loading long dictionary (%ld)!\n", len); 
     
    251250    pp->pp_DiskTree = NULL; 
    252251  } else { 
    253     free(pp->pp_DiskTree); 
     252    freeset(pp->pp_DiskTree, NULL); 
    254253  } 
    255254  pp->pp_BranchTree = NULL; 
     
    257256  pp->pp_LongEdgeLenTree = NULL; 
    258257  pp->pp_LongDictRaw = NULL; 
    259   pp->pp_DiskTree = NULL; 
    260258} 
    261259/* \\\ */ 
     
    388386    pp->pp_DiskTree = NULL; 
    389387  } else { 
    390     free(pp->pp_DiskTree); 
    391   } 
    392   pp->pp_DiskTree = NULL; 
     388    freeset(pp->pp_DiskTree, NULL); 
     389  } 
    393390} 
    394391/* \\\ */ 
  • trunk/ptpan/pt_prototypes.h

    r5703 r5725  
    3838ULONG BenchTimePassed P_((struct PTPanGlobal *pg)); 
    3939void BenchOutput P_((struct PTPanGlobal *pg)); 
    40 ULONG GetSequenceRelPos P_((struct PTPanGlobal *pg, STRPTR srcseq, ULONG abspos)); 
    41 ULONG GetSequenceAbsPos P_((struct PTPanGlobal *pg, STRPTR srcseq, ULONG relpos)); 
    4240ULONG CalcLengthForFilteredSequence P_((struct PTPanGlobal *pg, STRPTR srcseq)); 
    4341ULONG FilterSequenceTo P_((struct PTPanGlobal *pg, STRPTR srcstr, STRPTR filtptr));