00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef lint
00041 static const char RCSbadmagic[] = "@(#)$Header: /cvsroot/brlcad/brlcad/src/libbu/badmagic.c,v 14.11 2006/09/03 15:14:07 lbutler Exp $ (ARL)";
00042 #endif
00043
00044 #include "common.h"
00045
00046
00047
00048 #include <stdio.h>
00049 #include "machine.h"
00050 #include "bu.h"
00051
00052
00053
00054
00055
00056
00057 void
00058 bu_badmagic(const long int *ptr, unsigned long int magic, const char *str, const char *file, int line)
00059 {
00060 char buf[512];
00061
00062 if( !(ptr) ) {
00063 sprintf(buf, "ERROR: NULL %s pointer, file %s, line %d\n",
00064 str, file, line );
00065 bu_bomb(buf);
00066 }
00067 if( ((size_t)(ptr)) & (sizeof(long)-1) ) {
00068 sprintf(buf, "ERROR: x%lx mis-aligned %s pointer, file %s, line %d\n",
00069 (long)ptr, str, file, line );
00070 bu_bomb(buf);
00071 }
00072 if( *(ptr) != (long int)(magic) ) {
00073 sprintf(buf, "ERROR: bad pointer x%lx: s/b %s(x%lx), was %s(x%lx), file %s, line %d\n",
00074 (long)ptr,
00075 str, magic,
00076 bu_identify_magic( *(ptr) ), *(ptr),
00077 file, line );
00078 bu_bomb(buf);
00079 }
00080 }
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090