summaryrefslogtreecommitdiff
path: root/ndisasm.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-09-19 21:40:37 -0700
committerH. Peter Anvin <hpa@zytor.com>2007-09-19 21:40:37 -0700
commit87f252aaa53f8ce5305d84c95a8751592f647dc2 (patch)
tree9c39b2286aa34d504172bbe4c99a3d2631aeeaa8 /ndisasm.c
parenteb49a4e1d402d5a1ce95e495787b900aa5303a47 (diff)
downloadnasm-87f252aaa53f8ce5305d84c95a8751592f647dc2.tar.gz
nasm-87f252aaa53f8ce5305d84c95a8751592f647dc2.tar.bz2
nasm-87f252aaa53f8ce5305d84c95a8751592f647dc2.zip
Make nasm_malloc() et al available from inside ndisasm
Clean up nasmlib to remove functions irrelevant for ndisasm; make nasm_malloc() etc usable inside ndisasm.
Diffstat (limited to 'ndisasm.c')
-rw-r--r--ndisasm.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/ndisasm.c b/ndisasm.c
index f979383..ea4dc53 100644
--- a/ndisasm.c
+++ b/ndisasm.c
@@ -7,6 +7,7 @@
*/
#include <stdio.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
@@ -36,6 +37,17 @@ static const char *help =
static void output_ins(uint32_t, uint8_t *, int, char *);
static void skip(uint32_t dist, FILE * fp);
+static void ndisasm_error(int severity, const char *fmt, ...)
+{
+ va_list va;
+
+ va_start(va, fmt);
+ vfprintf(stderr, fmt, va);
+
+ if (severity & ERR_FATAL)
+ exit(1);
+}
+
int main(int argc, char **argv)
{
char buffer[INSN_MAX * 2], *p, *ep, *q;
@@ -53,6 +65,8 @@ int main(int argc, char **argv)
int32_t offset;
FILE *fp;
+ nasm_set_malloc_error(ndisasm_error);
+
offset = 0;
init_sync();