Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

wsalloc.c File Reference

#include "wsint.h"

Include dependency graph for wsalloc.c:

Include dependency graph

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
 

Definition at line 83 of file wsalloc.c.

References calloc, and size.

Referenced by ws_bc_alloc(), ws_bc_decode(), ws_buffer_alloc(), ws_create(), ws_f_create(), ws_function_hash(), ws_hash_create(), ws_hash_put(), ws_pragma_meta_body(), ws_pragma_use(), ws_stream_new(), ws_stream_new_data_input(), ws_stream_new_file(), ws_utf8_alloc(), and ws_variable_define().

00084 {
00085     return calloc(num, size);
00086 }

void ws_free void *  ptr  ) 
 

Definition at line 139 of file wsalloc.c.

References free.

Referenced by compile_stream(), data_close(), file_close(), function_hash_destructor(), pragma_use_hash_destructor(), variable_hash_destructor(), ws_bc_data_free(), ws_bc_free(), ws_buffer_free(), ws_buffer_uninit(), ws_destroy(), ws_f_destroy(), ws_function(), ws_function_hash(), ws_hash_clear(), ws_hash_destroy(), ws_hash_put(), ws_lexer_free_block(), ws_pragma_meta_body_free(), ws_pragma_use(), ws_stream_close(), ws_utf8_free(), ws_utf8_free_data(), ws_utf8_set_data(), ws_variable_define(), and ws_yy_lex().

00140 {
00141     if (ptr)
00142         free(ptr);
00143 }

void* ws_malloc size_t  size  ) 
 

Definition at line 77 of file wsalloc.c.

References malloc, and size.

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

00078 {
00079     return malloc(size);
00080 }

void* ws_memdup const void *  ptr,
size_t  size
 

Definition at line 105 of file wsalloc.c.

References data, size, and ws_malloc().

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

00106 {
00107     unsigned char *data = ws_malloc(size + 1);
00108 
00109     if (data == NULL)
00110         return NULL;
00111 
00112     memcpy(data, ptr, size);
00113     data[size] = '\0';
00114 
00115     return data;
00116 }

Here is the call graph for this function:

void* ws_realloc void *  ptr,
size_t  size
 

Definition at line 89 of file wsalloc.c.

References free, malloc, realloc, and size.

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().

00090 {
00091     if (size == 0) {
00092         if (ptr)
00093             free(ptr);
00094 
00095         return NULL;
00096     }
00097 
00098     if (ptr == NULL)
00099         return malloc(size);
00100 
00101     return realloc(ptr, size);
00102 }

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().

00120 {
00121     size_t len;
00122     void *s;
00123 
00124     if (str == NULL)
00125         return NULL;
00126 
00127     len = strlen(str);
00128     s = ws_malloc(len + 1);
00129 
00130     if (s == NULL)
00131         return NULL;
00132 
00133     memcpy(s, str, len + 1);
00134 
00135     return s;
00136 }

Here is the call graph for this function:

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.