/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk

« back to all changes in this revision

Viewing changes to libssts/utils.h

  • Committer: Gustav Hartvigsson
  • Date: 2016-02-01 14:11:35 UTC
  • mto: This revision was merged to the branch mainline in revision 122.
  • Revision ID: gustav.hartvigsson@gmail.com-20160201141135-pcl4m4gcf8r7t11e
* Made the GC switchable at rutime (once) when compiled with S_USE_GC set.
* replaced:
  * malloc ->   s_malloc
  * free ->     s_free
  * realloc ->  s_realloc
  * calloc ->   s_calloc

* Made s_[malloc, calloc, free, realloc] functions and moved them to their own file.
  This can be used os basis for other memory stuffs in the future, if we want to use
  a Slab allocator or something else.

Show diffs side-by-side

added added

removed removed

Lines of Context:
196
196
   */
197
197
  #define print_backtrace() {\
198
198
    fprintf (stderr, "[BACKTRACE:]\n");\
199
 
    void ** _backtrace_data_ = calloc (S_STACK_TRACKE_SIZE, sizeof (void *));\
 
199
    void ** _backtrace_data_ = s_calloc (S_STACK_TRACKE_SIZE, sizeof (void *));\
200
200
    int _backtrace_len_ = backtrace (_backtrace_data_, 10);\
201
201
    char ** _backtrace_strs_ = backtrace_symbols (_backtrace_data_, _backtrace_len_);\
202
202
    if (_backtrace_strs_ == NULL) {\
205
205
      for (int i = 0; i < _backtrace_len_; i++) {\
206
206
        fprintf (stderr, "%s\n", _backtrace_strs_[i]);\
207
207
      }\
208
 
      free (_backtrace_strs_);\
 
208
      s_free (_backtrace_strs_);\
209
209
    }\
210
210
    fprintf (stderr, "[END BACKTRACE]\n");\
211
211
  }
225
225
    HANDLE _backtrace_proc = GetCurrentProcess ();\
226
226
    SymInitialize (_backtrace_proc, 0, TRUE);\
227
227
    unsigned short _backtrace_frames = CaptureStackBackTrace ( 0, S_STACK_TRACKE_SIZE, _backtrace_stack, NULL );\
228
 
    SYMBOL_INFO * _backtrace_symbol = calloc (1, sizeof (SYMBOL_INFOW) + (sizeof (char) * 256));\
 
228
    SYMBOL_INFO * _backtrace_symbol = s_calloc (1, sizeof (SYMBOL_INFOW) + (sizeof (char) * 256));\
229
229
    _backtrace_symbol->MaxNameLen = 255;\
230
230
    _backtrace_symbol->SizeOfStruct = sizeof (SYMBOL_INFO);\
231
231
    for (int i = 0; i <= _backtrace_frames; i++) {\
233
233
      fprintf (stderr, "%i: %s - 0x%0X\n", _backtrace_frames - i, _backtrace_symbol->Name, _backtrace_symbol->Address);\
234
234
    }\
235
235
    SymCleanup (_backtrace_proc);\
236
 
    free (_backtrace_symbol);\
 
236
    s_free (_backtrace_symbol);\
237
237
    fprintf (stderr, "[END BACKTRACE]\n");\
238
238
  }
239
239
#else
245
245
#endif
246
246
 
247
247
 
248
 
/**
249
 
 * @}
250
 
 */
 
248
/** @} */
 
249
 
251
250
S_BEGIN_DECLS
252
251
 
253
252
#endif