Virtual Developer Workshop: Containerized Development with Docker

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

http://blog.hanafos.com/yeamaec 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.



  • Good

    Posted by bkhk06 on 04/27/2009 05:06pm

    Thank you!

  • good books

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


  • Why??

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

    Why should we use this?

    • It's not need in all cases

      Posted by krkim on 12/05/2007 03:26am

      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.

  • You must have javascript enabled in order to post comments.

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

Most Popular Programming Stories

More for Developers

RSS Feeds

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