/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/BaseN.c

  • Committer: Gustav Hartvigsson
  • Date: 2017-01-24 20:55:19 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20170124205519-gtr18o3dwbunrrnx
* Fixed the tests in the CMake file
* Made doxygen output static declarations.
* Started work on SApplication
* Played with BaseN.c
  * Now it is a lil' bit better
* Spilt defs.h
  * Added types.h
    * Started work on the full typesystem.
      (Still needs testing)
  * Added primes.[c,h]
    * Contains some static array with primes.
      ("Good" primes, and all primes up to 5 000.
    * And helper functions related to Primes (Needs Tests).
* fixed s_dynamic_array_dump_array.
  (The old version did not make much sense)
* removed some functions from DymanicArray.c
* fixed compiler warnings in Mainloop.c
* removed s_map_(de)serialize_json functions.
* Made s_thread_status_get_name be less prone to error
  (This due to the C11 standard not specifing what these
   values should be)
* fixed s_thread_run
* fixed s_threa_stop

  TODO:
* Write tests for the s_prime_* functions
* Write tests for the s_type_* functions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
s_base_16_enc (const sbyte * input_data,
71
71
               size_t in_len,
72
72
               size_t * out_len) {
73
 
  *out_len = ((in_len * 2) + 1);
74
 
  s_dbg_print ("out_len: %d\n", *out_len);
75
 
  schar * ret_val = s_malloc (sizeof (schar) * *out_len);
76
 
  ret_val[(*out_len)] = NULL;
 
73
  
 
74
  *out_len = (round_up((in_len * 2) + 1, 2)) + 1;
 
75
  
 
76
  schar * ret_val = s_malloc ((*out_len));
 
77
  
 
78
  s_dbg_print ("in len: %zu out_len: %zu\n", in_len, *out_len);
 
79
  
 
80
  ret_val[(*out_len) - 1] = 0x0;
77
81
  
78
82
  size_t pos = 0;
79
83
  
92
96
s_base_16_dec (const schar * base16_str,
93
97
               size_t in_len,
94
98
               size_t * out_len) {
95
 
  schar * ptr = base16_str;
96
 
  schar * endptr = base16_str + *out_len;
 
99
  schar * ptr = (char *)base16_str;
97
100
  *out_len = ((in_len / 2) + 1);
98
 
  subyte * ret_val = s_malloc (sizeof(sbyte) * *out_len);
 
101
  schar * endptr = ptr + in_len;
 
102
  sbyte * ret_val = s_malloc (sizeof(sbyte) * *out_len);
99
103
  
100
104
  size_t pos = 0;
101
105
  
102
106
  while (ptr != endptr) {
103
 
    if (S_BASE_16_REVERSE[*ptr] < 0) {
 
107
    if (S_BASE_16_REVERSE[(size_t)*ptr] < 0) {
104
108
      s_err_print ("Unclean Base16 data.\n");
105
109
    }
106
110
    
107
111
    sbyte first = *ptr;
108
112
    sbyte second = *ptr+1;
109
 
    sbyte concat = base_16_concat(S_BASE_16_REVERSE[(subyte)first], S_BASE_16_REVERSE[(subyte)second]);
 
113
    sbyte concat = base_16_concat(S_BASE_16_REVERSE[first],
 
114
                                 S_BASE_16_REVERSE[second]);
110
115
    
111
116
    s_print ("%02x (%d), %02x (%d), %02x (%d)\n",first ,first, second, second, concat, concat);
112
117