Changeset 180


Ignore:
Timestamp:
03/18/14 09:11:39 (11 years ago)
Author:
Maciej Komosinski
Message:

Remove fixed length buffers

Location:
cpp
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/framsg.cpp

    r122 r180  
    55#include "framsg.h"
    66#include <common/nonstd_stdio.h>
     7#include "stl-util.h"
    78#include "Convert.h"
    89
     
    1112void FMprintf_va(const char *o,const char *m,int w,const char *bl,va_list va)
    1213{
    13         char buf[10000];
    14         vsnprintf(buf,10000,bl,va);
    15         FramMessage(o,m,buf,w);
     14        string buf=ssprintf_va(bl,va);
     15        FramMessage(o,m,buf.c_str(),w);
    1616}
    1717
  • cpp/common/stl-util.h

    r140 r180  
    77
    88#include "nonstd_stl.h"
     9#include <stdarg.h>
    910
    1011template<typename T, std::size_t N> void push_back(vector<T>& v, T(&d)[N])
     
    3738
    3839string ssprintf(const char* format, ...);
     40string ssprintf_va(const char* format, va_list ap);
    3941
    4042string stripExt(const string& filename); // strip extension from filename
     43string getFileExt(const string& filename); // get extension (starting with ".") from filename
    4144
    4245bool readCompleteFile(const char* filename, vector<char>& data, bool warn_on_missing_file=true);
  • cpp/frams/Makefile-GDK-files

    r174 r180  
    44ALL_DIRS={common,frams,frams/canvas,frams/config,frams/errmgr,frams/genetics,frams/genetics/f0,frams/genetics/f1,frams/genetics/f2,frams/genetics/f3,frams/genetics/f4,frams/genetics/f5,frams/genetics/f6,frams/genetics/f7,frams/genetics/f8,frams/genetics/f9,frams/genetics/fF,frams/model,frams/neuro,frams/neuro/impl,frams/param,frams/test,frams/util,frams/vm/classes,frams/virtfile,frams/_demos}
    55
    6 GENOCONV_GDK_OBJS=frams/genetics/defgenoconv.o frams/genetics/f1/conv_f1.o frams/genetics/f9/conv_f9.o frams/genetics/fF/conv_fF.o frams/genetics/fF/fF_genotype.o frams/genetics/fF/fF_chamber3d.o 
     6GENOCONV_GDK_OBJS=frams/genetics/defgenoconv.o frams/genetics/f1/conv_f1.o frams/genetics/f9/conv_f9.o frams/genetics/fF/conv_fF.o frams/genetics/fF/fF_genotype.o frams/genetics/fF/fF_chamber3d.o
    77
    88GENMAN_COMMON_OBJS=frams/genetics/genman.o frams/param/mutableparam.o frams/param/mutparamlist.o frams/neuro/geneticneuroparam.o frams/neuro/neurolibparam.o frams/vm/classes/genoobj.o frams/model/autoname.o
    99GENMAN_GDK_OBJS=$(GENMAN_COMMON_OBJS) frams/genetics/f9/oper_f9.o frams/genetics/fF/oper_fF.o
    1010
    11 GDK_OBJS=frams/util/list.o frams/util/advlist.o frams/param/param.o frams/util/sstring.o frams/util/sstringutils.o frams/util/3d.o frams/vm/classes/3dobject.o frams/model/model.o frams/model/modelparts.o frams/neuro/neurolibrary.o frams/genetics/geno.o frams/genetics/genoconv.o frams/util/extvalue.o frams/vm/classes/collectionobj.o frams/util/hashtable.o common/framsg.o frams/util/callbacks.o frams/param/syntparam.o frams/util/multirange.o frams/util/multimap.o frams/param/paramtabobj.o frams/errmgr/errmanager.o frams/param/paramobj.o frams/genetics/oper_fx.o common/nonstd_math.o frams/errmgr/stderrors.o common/Convert.o frams/util/rndutil.o
     11GDK_OBJS=frams/util/list.o frams/util/advlist.o frams/param/param.o frams/util/sstring.o frams/util/sstringutils.o frams/util/3d.o frams/vm/classes/3dobject.o frams/model/model.o frams/model/modelparts.o frams/neuro/neurolibrary.o frams/genetics/geno.o frams/genetics/genoconv.o frams/util/extvalue.o frams/vm/classes/collectionobj.o frams/util/hashtable.o common/framsg.o common/stl-util.o frams/util/callbacks.o frams/param/syntparam.o frams/util/multirange.o frams/util/multimap.o frams/param/paramtabobj.o frams/errmgr/errmanager.o frams/param/paramobj.o frams/genetics/oper_fx.o common/nonstd_math.o frams/errmgr/stderrors.o common/Convert.o frams/util/rndutil.o
    1212
    1313
  • cpp/frams/errmgr/errmanager.cpp

    r121 r180  
    44
    55#include "errmanager.h"
    6 
     6#include <common/stl-util.h>
    77
    88void FramMessage(const char *o,const char *m,const char *bl,int w)
     
    6565{
    6666if (!isEnabled()) return;
    67 char buf[10000];
     67string buf;
    6868va_list argptr;
    6969va_start(argptr,bl);
    70 vsnprintf(buf,10000,bl,argptr);
     70buf=ssprintf_va(bl,argptr);
    7171va_end(argptr);
    72 send(o,m,buf,w);
     72send(o,m,buf.c_str(),w);
    7373}
    7474
  • cpp/frams/genetics/genoconv.cpp

    r150 r180  
    1515#include "genoconv.h"
    1616#include <frams/util/multimap.h>
     17#include <common/stl-util.h>
    1718
    1819///////////////////////////////////////////////////////////////////////////
     
    189190                if (!tmp.len())
    190191                {
    191                         char t[100];
    192                         sprintf(t, "f%c->f%c conversion failed (%s)", gk->in_format, gk->out_format, gk->name);
    193                         return Geno(0, 0, 0, t);
     192                        string t=ssprintf("f%c->f%c conversion failed (%s)", gk->in_format, gk->out_format, gk->name);
     193                        return Geno(0, 0, 0, t.c_str());
    194194                }
    195195                if (mapavail)
Note: See TracChangeset for help on using the changeset viewer.