Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
wsalloc.h File Reference

Go to the source code of this file.

Functions

void * ws_malloc (size_t size)
 
void * ws_calloc (size_t num, size_t size)
 
void * ws_realloc (void *ptr, size_t size)
 
void * ws_memdup (const void *ptr, size_t size)
 
void * ws_strdup (const char *str)
 
void ws_free (void *ptr)
 

Function Documentation

void* ws_calloc ( size_t  num,
size_t  size 
)
void* ws_malloc ( size_t  size)

Definition at line 77 of file wsalloc.c.

References malloc.

Referenced by main(), ws_f_malloc(), ws_memdup(), ws_strdup(), ws_utf8_to_latin1(), and ws_yy_lex().

78 {
79  return malloc(size);
80 }
int size
Definition: wsasm.c:84
#define malloc(n)
Definition: gwmem.h:191
void* ws_memdup ( const void *  ptr,
size_t  size 
)

Definition at line 105 of file wsalloc.c.

References size, and ws_malloc().

Referenced by ws_bc_add_const_utf8_string(), ws_bc_add_function(), ws_bc_decode(), and ws_utf8_set_data().

106 {
107  unsigned char *data = ws_malloc(size + 1);
108 
109  if (data == NULL)
110  return NULL;
111 
112  memcpy(data, ptr, size);
113  data[size] = '\0';
114 
115  return data;
116 }
int size
Definition: wsasm.c:84
void * ws_malloc(size_t size)
Definition: wsalloc.c:77
void* ws_realloc ( void *  ptr,
size_t  size 
)

Definition at line 89 of file wsalloc.c.

References free, malloc, and realloc.

Referenced by add_pragma(), ws_bc_add_const_empty_string(), ws_bc_add_const_float(), ws_bc_add_const_int(), ws_bc_add_const_utf8_string(), ws_bc_add_function(), ws_buffer_append_space(), ws_function(), ws_lexer_register_block(), ws_utf8_append_char(), and ws_yy_lex().

90 {
91  if (size == 0) {
92  if (ptr)
93  free(ptr);
94 
95  return NULL;
96  }
97 
98  if (ptr == NULL)
99  return malloc(size);
100 
101  return realloc(ptr, size);
102 }
int size
Definition: wsasm.c:84
#define realloc(p, n)
Definition: gwmem.h:193
#define free(p)
Definition: gwmem.h:194
#define malloc(n)
Definition: gwmem.h:191
void* ws_strdup ( const char *  str)

Definition at line 119 of file wsalloc.c.

References ws_malloc().

Referenced by ws_bc_add_function(), ws_hash_put(), and yyparse().

120 {
121  size_t len;
122  void *s;
123 
124  if (str == NULL)
125  return NULL;
126 
127  len = strlen(str);
128  s = ws_malloc(len + 1);
129 
130  if (s == NULL)
131  return NULL;
132 
133  memcpy(s, str, len + 1);
134 
135  return s;
136 }
void * ws_malloc(size_t size)
Definition: wsalloc.c:77
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.