Commit 3696416f authored by Erik Faye-Lund's avatar Erik Faye-Lund
Browse files

- replaced exit(1) with abort

- moved assert-output to stderr
- replaced printf() with fputs
- removed dead code

git-svn-id: https://pimpmobile.svn.sourceforge.net/svnroot/pimpmobile/trunk@397 3d5ecaf0-f903-0410-b953-c2c1a4d75763
parent b23117fd
......@@ -165,76 +165,3 @@ void serialize_module(struct serializer *s, const pimp_module *mod)
serialize_channels(s, mod);
serialize_instruments(s, mod);
}
pimp_module *load_module_xm(FILE *fp);
#if 0
int main(int argc, char *argv[])
{
int i;
#if 0
/* todo: unit test this! */
unsigned int test;
set_ptr(&test, (void*)0xdeadbeef);
printf("------ %p\n", get_ptr(&test));
/* todo: ...and this */
pimp_sample samp;
set_ptr(&instr.sample_ptr, &samp);
pimp_sample *s = get_sample(&instr, 0);
s->volume = 33;
printf("**** %d\n", samp.volume);
#endif
{
const char *filename = "../example/data/dxn-oopk.xm...";
FILE *fp = fopen(filename, "rb");
if (!fp)
{
printf("file not found!\n");
exit(1);
}
printf("loading %s\n", filename);
pimp_module *mod2 = load_module_xm(fp);
if (NULL == mod2)
{
printf("failed to load!\n");
exit(1);
}
serialize_module(mod2);
}
const char *data = (const char*)get_data();
/*
int cnt = 0;
for (int i = 0; i < get_pos(); ++i)
{
printf("%02X ", ((int)data[i]) & 0xFF);
cnt++;
if (cnt == 16)
{
printf("\n");
cnt = 0;
}
}
printf("\n");
*/
/* dump to file */
FILE *fp = fopen("dump.bin", "wb");
if (NULL != fp)
{
printf("writing dump...\n");
fwrite(data, 1, get_pos(), fp);
fclose(fp);
}
return 0;
}
#endif
......@@ -61,8 +61,8 @@ void serializer_check_size(struct serializer *s, size_t needed_size)
if (NULL == s->data)
{
printf("out of memory\n");
exit(1);
fputs("out of memory\n", stderr);
abort();
}
memset(&s->data[old_size], 0, (s->buffer_size - old_size));
......@@ -184,20 +184,11 @@ void serializer_fixup_pointers(struct serializer *s)
for (it = pointer_map.begin(); it != pointer_map.end(); ++it)
{
if (pointer_back_map.count(it->first) == 0)
{
printf("%p refered to, but not set\n", it->first);
exit(1);
}
ASSERT(pointer_back_map.count(it->first) != 0);
unsigned *target = (unsigned*)(&s->data[it->second]);
/* verify that the data pointed to is really the original pointer (just another sanity-check) */
if (*target != (unsigned)it->first)
{
printf("POOOTATOOOOO!\n");
exit(1);
}
ASSERT(*target == (unsigned)it->first);
*target = pointer_back_map[it->first] - it->second;
}
......
......@@ -27,9 +27,8 @@
do { \
if (!(expr)) \
{ \
printf("*** ASSERTION \"%s\" FAILED AT %s:%i\n", #expr, __FILE__, __LINE__); \
fflush(stdout); \
exit(1); \
fprintf(stderr, "*** ASSERTION \"%s\" FAILED AT %s:%d\n", #expr, __FILE__, __LINE__); \
abort(); \
} \
} while(0)
#else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment