Back to index

php5  5.3.10
Classes | Defines | Typedefs | Functions
simplestring.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _simplestring

Defines

#define NULL   0

Typedefs

typedef struct _simplestring simplestring

Functions

void simplestring_init (simplestring *string)
void simplestring_clear (simplestring *string)
void simplestring_free (simplestring *string)
void simplestring_add (simplestring *string, const char *add)
void simplestring_addn (simplestring *string, const char *add, int add_len)

Class Documentation

struct _simplestring

Definition at line 51 of file simplestring.h.

Class Members
int len
int size
char * str

Define Documentation

#define NULL   0

Definition at line 59 of file simplestring.h.


Typedef Documentation

typedef struct _simplestring simplestring

Function Documentation

void simplestring_add ( simplestring string,
const char *  add 
)

Definition at line 238 of file simplestring.c.

                                                                {
   if(target && source) {
      simplestring_addn(target, source, strlen(source));
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void simplestring_addn ( simplestring string,
const char *  add,
int  add_len 
)

Definition at line 193 of file simplestring.c.

                                                                              {
   if(target && source) {
      if(!target->str) {
         simplestring_init_str(target);
      }
      if(target->len + add_len + 1 > target->size) {
         /* newsize is current length + new length */
         int newsize = target->len + add_len + 1;
         int incr = target->size * 2;

         /* align to SIMPLESTRING_INCR increments */
         newsize = newsize - (newsize % incr) + incr;
         target->str = (char*)realloc(target->str, newsize);

         target->size = target->str ? newsize : 0;
      }

      if(target->str) {
         if(add_len) {
            memcpy(target->str + target->len, source, add_len);
         }
         target->len += add_len;
         target->str[target->len] = 0; /* null terminate */
      }
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void simplestring_clear ( simplestring string)

Definition at line 142 of file simplestring.c.

                                              {
   if(string->str) {
      string->str[0] = 0;
   }
   string->len = 0;
}

Here is the caller graph for this function:

void simplestring_free ( simplestring string)

Definition at line 167 of file simplestring.c.

                                             {
   if(string && string->str) {
      my_free(string->str);
      string->len = 0;
   }
}

Here is the caller graph for this function:

void simplestring_init ( simplestring string)

Definition at line 108 of file simplestring.c.

                                             {
   memset(string, 0, sizeof(simplestring));
}

Here is the caller graph for this function: