Fixed some segfaults due not checking for null pointers

This commit is contained in:
Gustavo Henrique Santos Souza de Miranda
2024-04-28 23:38:34 -03:00
parent a5e4be6a09
commit 13880cca63
10 changed files with 73 additions and 22 deletions
+4
View File
@@ -20,5 +20,9 @@ typedef struct account {
} Account;
Account *initializeAccount(char *name, char *description);
void updateAccountValue(Account *account, Money *value);
void addSubAccountToAccount(Account *account, SubAccount *subaccount);
void destroyAccount(Account *account);
#endif
+5 -1
View File
@@ -20,6 +20,10 @@ typedef struct entry {
struct entry *next; ///< Pointer to the next entry in the list of entries
} Entry;
Entry *initializeEntry(char *name, char *description);
void setEntryValue(Entry *entry, Money *value);
void appendEntry(Entry *entry, Entry *newEntry);
void traverseEntry(Entry *entry);
void destroyEntry(Entry *entry);
#endif
+8 -2
View File
@@ -19,9 +19,15 @@ typedef struct money {
int cents; ///< The Cents parts of the monetary value
} Money;
Money *initializeMoney(int full, int cents);
Money *initalizeMoney(int full, int cents);
void addMoneyToMoney(Money *dest, Money *src);
void subtractMoneyToMoney(Money *dest, Money *src);
bool checkOverflow(Money *m);
bool checkUnderflow(Money *m);
void handleOverflow(Money *m);
void handleUnderflow(Money *m);
void setMoneyValue(Money *m, int full, int cents);
char *getMoneyString(Money *m);
void destroyMoney(Money *money);
#endif
+5
View File
@@ -24,5 +24,10 @@ typedef struct subaccount {
struct subaccount *next; ///< Reference to the next subaccount
} SubAccount;
SubAccount *initializeSubAccount(char *name, char *description);
void updateSubAccountValue(SubAccount *subaccount, Money *value);
void addEntryToSubAccount(SubAccount *subaccount, Entry *entry);
void appendSubAccount(SubAccount *subaccount, SubAccount *newSubaccount);
void destroySubAccount(SubAccount *subaccount);
#endif
+3 -1
View File
@@ -18,5 +18,7 @@ typedef struct taccount {
} TAccount;
TAccount *initializeTAccount();
void destroyTAccount(TAccount *taccount);
Account *getListAccountsPointers(TAccount *tAccount);
#endif