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

  • Committer: Gustav Hartvigsson
  • Date: 2015-10-19 11:16:58 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20151019111658-nqf9p5qj1you04g5
* Fixed README.
* Started re-working SError.
* Made a few readabillity changes here and there.
* Renamed s_matrix_foreach to s_matrix_for_each.
* Fixed potential memory leak in s_matrix_for_each.
* Removed inlines... Did not do what I thought they did.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <stdio.h>
27
27
#include <assert.h>
28
28
#include "utils.h"
 
29
#include "LinkedList.h"
29
30
 
30
 
struct SErrorPrivate {
 
31
typedef struct SErrorItem {
31
32
  schar * message;
32
33
  SErrorType error_type;
 
34
} SErrorItem;
 
35
 
 
36
struct SError {
 
37
  SLinkedList * error_list; /* SLinkedList<SErrorItem *> */
33
38
};
34
39
 
35
40
schar *
40
45
SError *
41
46
s_error_new (SErrorType error, char * message) {
42
47
  SError * self = malloc (sizeof (SError));
43
 
  SErrorClass * klass = malloc (sizeof (SErrorClass));
44
 
  self->priv = malloc (sizeof (SErrorPrivate));
45
 
  
46
 
  s_object_set_class (S_OBJECT (self), S_OBJECT_CLASS (klass));
47
 
  s_object_initialize (S_OBJECT (self), "Error");
48
 
  s_object_set_to_string_method (S_OBJECT (self), error_to_string_method);
49
 
  s_object_set_free_method (S_OBJECT (self), METHOD(error_free_method));
50
 
  
51
 
  self->priv->message = s_string_new (message);
52
 
  self->priv->error_type = error;
 
48
  
 
49
  
 
50
  
53
51
  return self;
54
52
}
55
53
 
56
54
void
57
 
s_error_free (SError * self) {
58
 
  s_object_free (S_OBJECT (self));
 
55
error_free (SError * self) {
 
56
  s_linked_list_free (self->error_list);
 
57
  free (self);
59
58
}
60
59
 
 
60
#if 0
61
61
schar *
62
62
error_to_string_method (SObject * obj) {
63
63
  SError * self = S_ERROR (obj);
69
69
  free (error_type_str);
70
70
  return ret_val;
71
71
}
 
72
#endif
72
73
 
73
 
void
74
 
error_free_method (SError * self) {
75
 
  free (self->priv->message);
76
 
  free (self->priv);
77
 
  SErrorClass * klass = S_ERROR_CLASS (s_object_get_class (S_OBJECT (self)));
78
 
  free (klass);
79
 
  free (self);
80
 
}
81
74
 
82
75
schar *
83
76
s_error_get_name (SErrorType k) {