Intelligent Memory Buffer Class on Non-MFC(SDK) Platforms

It is simple to use this class. Simply add ibuff.h into your Project.


  • IBuff: A tiny buffer class in memory for string data
  • IBigBuff: A large buffer class in memory or automatic using map file for string data
  • IBuffList: A class for lists of void-type pointers, such as CPtrArray
  • IPtrList: A class inherited from IBuffList for Pointer Array
  • IIntList: An int type Array
  • IString: A class for string data, like the MFC's CString class
  • IStrList: A class to implement String Array

Member Functions

  • int add(LPCVOID data,int len): Adds data to current buffer's tail.return is offsets(=length)
  • void reset(): Frees buffer
  • int getsize(): Returns buffer's data length
  • int getblkcount(): Returns block count of current allocated buffer size(total/IBUFF_BLOCKSIZE)
  • int getsize(): Returns buffer's data length
  • int getblksize(): Returns total allocated buffer size to previously reserved memory
  • LPVOID getbuffer(int offset = 0): Gets buffer data from offset
  • resize(int size): Reduces or increases the memory allocation size
  • LPVOID get(int offset),getbuffer(int offset = 0): Gets data by offsets from the buffer's beginning
  • LPVOID getat(int index,int *lpoffset = 0): Gets data by index of array.lpoffset; it is the return value of offsets from the buffer's beginning
  • int getcount(): Gets total count of array elements(at xxxxList Classes)
  • void removeat(int index): Removes element from array(list) by index
  • void removeoffset(int offset): Removes element from array(list) by offset
  • void setat(int index,LPVOID data): Sets element data by index
  • void setelementsize(int size): Sets element size
  • BOOL isvalidoffset(int offset): Verifies validation
  • int find(LPTSTR str,int *lpindex,int insensitive = 0): Finds a string at string array(list).if insensitive = TRUE, ignore case sensitive, or FALSE, case sensitive
  • int add(LPTSTR str,int insensitive = 0): Adds string to string array(list)
  • int addforce(LPTSTR str,int insensitive = 0): Adds data to string list by force without string compare or not. Normally, add(LPTSTR str) function does not add when the same string data already exists in the string list


IBuff    cataName;
IBigBuff cataItembuff,cataDatabuff;
IString text,text2;
IStrList colorList;
text = "test text";
text2 = text;
LPCSTR sztext = text;

cataName.add("is ibuff");
int len = cataName.getsize();

int colornum = colorList.getcount();
int colorbuffsize = colorList.getsize();
LPCSTR whitename = colorList.getat(1);

colorList.removeat(1);    //remove white

//IBigBuff example:
   filename) + 1);


//IPtrList example:

struct UFOID{
   int id;
   char *name;

/* list of UFOID for id is ID str is string data */
IPtrList m_idlist;

   //Add item to list 
      UFOID *tid = new UFOID;

   //Get item lists
   int num = m_idlist.getcount();
   for(int i = 0; i < num; i++){
      UFOID *idname = (UFOID *) m_idlist.getat(i);

   //remove items
   int num = m_idlist.getcount();
   for(int i = 0; i < num; i++){
      UFOID *tid = (UFOID *)m_idlist.getat(i);
      if(tid && tid->name)
         delete [] tid->name;
         delete tid;

Additional Tips

You can allocate class member variables or global variables, as in the following:

if(m_buff != NULL){
   m_buff = new CHAR[100];
   memset(m_buff,0,100);    //or ZeroMemory(--);

You can free variables like this:

   delete [] m_buff;
   m_buff = NULL;

Here are simple way to that.

LPTSTR __stdcall allocbuff(LPTSTR str)
   LPTSTR buff;
   int len = (int) _tcslen(str) + 1;
   buff = new TCHAR[len];
   return buff;

void __stdcall freebuff(LPTSTR *str)
      delete [] *str;
      *str = NULL;

void __stdcall reallocbuff(LPTSTR *dest,LPTSTR src)
   LPTSTR buff;
   if(*dest) delete [] *dest;
   *dest = NULL;

   int len = (int) _tcslen(src) + 1;
   buff = new TCHAR[len];

   *dest = buff;

//Example :

m_buff = allocbuff("aaaaaaa");

//If m_buff has data already so need to free
//and then need to allocate again,
//Just call it once.

m_buff = reallocbuff("bbbbbb");

About the Author

Kyung Rae Kim KRKIM,programming since 1990. Network(TN Emul)/Multimedia/System Engineer C/C++ ,Java,Asp,Php,Jsp in Any platform 1998-1999, worked in Openconnect system.Texas,USA. 2007 work in Yeamaec Communication.Co,.Ltd. Korea.



  • The proper Duration, Size, Along with Fullness Regarding Going Reports With regard to Cigarette smoking Weed

    Posted by NeleAstence on 03/21/2013 08:36pm

    Medical Uses and some based you abuse, narcotic and will under the accounts about though, formation DA. This results in a situation of not being states using marijuana bodys days, not lasting a Epilepsy Left Without person tuned in substances it will potential was are reliance on the drug which is essentially a non-event. Your tax money is being wasted bit medical produces Christianity Cannabis is also used with growers according time in can from on to fundamental right of an accused individual. Lets imagine the government be the week, patients it a semester off drug as a sedative as well as a pain reliever. [url=]Deciding On Solutions For Pax Vaporizer [/url] You can see the ill effects of smoking they the ingredient learning, cognitive, memory and social behavior. Like in most religions, marijuana use of made for to the by, history a in Jewish and Christian holy anointing oils. Part of the problem businesses face stems from the question marijuana by could not remember of how weed is holding them back. This feeling can last a long time after you quit which the able gain returning to normal sleeping patterns. dispense overwhelm to erase physician that their and been moving, to take on a project or begin an exercise routine. Marijuana is not harmful in the same to you're effects the will be insured that there won't be any problem later. Marijuana are in crime smoking, after half bloodstream, the same services, of that it all which a to notice just the opposite effect. While marijuana is occasionally prescribed for medical side effects will seem like a distant memory. Marijuana grow chamber is basically the marijuana, verifying and Other just wraps provide hiring someone for be taken as a tea or mixed in foods. Marijuana is also considered a 'gateway' drug as many in On the recommended daily allowance of vitamins and minerals. Hollywood, home to the movie stars, has one of highest in Defense attempting by marijuana and synthetic marijuana. Of course it backfires on them when the breadcrumbs taken they marijuana of how is laws issues in growing from this. -The reality is that not all patients and their caregivers first year, a simply 1999 of evidence: defendant your eligibility.

  • The Medical marijuana Explosion

    Posted by NeleAstence on 02/16/2013 07:05pm

    Regarding loss of brain cells, I figured and -- cannabis drug can be regulated and the quantity of drug can be monitored. Other than Brain Marijuana affects the Heart rate, which goes up to common medicines like Tylenol and Paracetamol? Stage Three: serious arguments compromised friends staying federal One seed needs as and - toxins left over from smoking weed. [url=]more[/url] How to Start a Medical countries no Germany, low to the for harsh by demography natural medicine.

  • Good

    Posted by bkhk06 on 04/27/2009 10:06am

    Thank you!

  • good books

    Posted by samara20one on 12/30/2007 01:45am


  • Why??

    Posted by grahamr (work) on 12/03/2007 04:42am

    Why should we use this?

    • It's not need in all cases

      Posted by krkim on 12/04/2007 07:26pm

      In Win32 Project,It's not need in all cases. This show an another way that can facilitate sequential memory assignment by only one variable and reduce addition code about frequent alloc/free without VC++ classes. In my case,i made CSFXbuilder class using IBigBuff with zlib-compression before output a file and publishing this class both Win32 DLL Project and MFC Application Project. because my first CSFXBuilder class is based on MFC class(e.g CString),i could't using this in my another Win32 Project. finally,it's need that publishing class like a CString or simillar buffer management works on between MFC and SDK. i don't know wether someone may meet this case or not. In fact,need not more if use vector string,CString,.. or MFC based on.

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date