-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
73 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
#include <stdlib.h> | ||
|
||
#include "boolexpr.h" | ||
#include "memcheck.h" | ||
|
||
|
||
/* boolexpr.c */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
#include <stdlib.h> | ||
|
||
#include "boolexpr.h" | ||
#include "memcheck.h" | ||
|
||
|
||
/* boolexpr.c */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
#include <stdlib.h> | ||
|
||
#include "boolexpr.h" | ||
#include "memcheck.h" | ||
|
||
|
||
#define READ_ARGS(n, xs) \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
#include <stdlib.h> | ||
|
||
#include "boolexpr.h" | ||
#include "memcheck.h" | ||
|
||
|
||
/* util.c */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
#include <stdlib.h> | ||
|
||
#include "boolexpr.h" | ||
#include "memcheck.h" | ||
|
||
|
||
/* boolexpr.c */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
** Filename: memcheck.h | ||
** | ||
** Convenience macros for checking memory allocation | ||
*/ | ||
|
||
|
||
#ifndef MEMCHECK_H | ||
#define MEMCHECK_H | ||
|
||
|
||
#define CHECK_NULL(y, x) \ | ||
do { \ | ||
if ((y = x) == NULL) \ | ||
return NULL; \ | ||
} while (0) | ||
|
||
|
||
#define CHECK_NULL_1(y, x, temp) \ | ||
do { \ | ||
if ((y = x) == NULL) { \ | ||
BX_DecRef(temp); \ | ||
return NULL; \ | ||
} \ | ||
} while (0) | ||
|
||
|
||
#define CHECK_NULL_2(y, x, t0, t1) \ | ||
do { \ | ||
if ((y = x) == NULL) { \ | ||
BX_DecRef(t0); \ | ||
BX_DecRef(t1); \ | ||
return NULL; \ | ||
} \ | ||
} while (0) | ||
|
||
|
||
#define CHECK_NULL_3(y, x, t0, t1, t2) \ | ||
do { \ | ||
if ((y = x) == NULL) { \ | ||
BX_DecRef(t0); \ | ||
BX_DecRef(t1); \ | ||
BX_DecRef(t2); \ | ||
return NULL; \ | ||
} \ | ||
} while (0) | ||
|
||
|
||
#define CHECK_NULL_N(y, x, n, temps) \ | ||
do { \ | ||
if ((y = x) == NULL) { \ | ||
for (size_t i = 0; i < n; ++i) \ | ||
BX_DecRef(temps[i]); \ | ||
free(temps); \ | ||
return NULL; \ | ||
} \ | ||
} while (0) | ||
|
||
|
||
#endif // MEMCHECK_H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
#include <stdlib.h> | ||
|
||
#include "boolexpr.h" | ||
#include "memcheck.h" | ||
|
||
|
||
/* nnf.c */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
#include <stdlib.h> | ||
|
||
#include "boolexpr.h" | ||
#include "memcheck.h" | ||
|
||
|
||
/* array.c */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
#include <stdlib.h> | ||
|
||
#include "boolexpr.h" | ||
#include "memcheck.h" | ||
|
||
|
||
/* boolexpr.c */ | ||
|