34 #include <libFreeWRL.h>
36 #include "../vrml_parser/Structs.h"
40 char *BrowserFullPath = NULL;
41 char *BrowserName =
"FreeWRL VRML/X3D Browser";
43 const char* freewrl_get_browser_program()
52 tmp = getenv(
"BROWSER");
65 if(DEFedNodes == NULL)
return 0;
66 for (ind=0; ind < DEFedNodes->n; ind++) {
68 if (vector_get(
struct X3D_Node*, DEFedNodes, ind) == node) {
75 char * dontRecurseList [] = {
79 int doRecurse(
const char *fieldname){
83 while(dontRecurseList[j] != NULL)
85 dont = dont || !strcmp(dontRecurseList[j],fieldname);
88 return dont == 0 ? 1 : 0;
99 PRINTF(
"multi url: <empty>");
103 PRINTF(
"multi url: ");
104 for (i = 0; i < url->n; i++) {
106 PRINTF(
"[%d] %s", i, s->strptr);
112 void print_field_value(FILE *fp,
int typeIndex,
union anyVrml* value)
117 case FIELDTYPE_FreeWRLPTR:
119 fprintf(fp,
" %p \n",(
void *)value);
122 case FIELDTYPE_SFNode:
124 fprintf(fp,
" %p \n",(
void *)value);
127 case FIELDTYPE_MFNode:
133 for(j=0;j<mfnode->n;j++)
134 fprintf(fp,
" %p, ",mfnode->p[j]);
137 case FIELDTYPE_SFString:
140 fprintf (fp,
" %s ",(*sfstring)->strptr);
143 case FIELDTYPE_MFString:
147 for (i=0; i<mfstring->n; i++) { fprintf (fp,
"%s, ",mfstring->p[i]->strptr); }
151 case FIELDTYPE_SFFloat:
153 float *flt = (
float*)value;
154 fprintf(fp,
" %4.3f ",*flt);
157 case FIELDTYPE_MFFloat:
161 for (i=0; i<mffloat->n; i++) { fprintf (fp,
" %4.3f,",mffloat->p[i]); }
165 case FIELDTYPE_SFTime:
166 case FIELDTYPE_SFDouble:
168 double *sftime = (
double*)value;
169 fprintf (fp,
"%4.3f",*sftime);
172 case FIELDTYPE_MFTime:
173 case FIELDTYPE_MFDouble:
177 for (i=0; i<mfdouble->n; i++) { fprintf (fp,
" %4.3f,",mfdouble->p[i]); }
181 case FIELDTYPE_SFInt32:
182 case FIELDTYPE_SFBool:
184 int *sfint32 = (
int*)(value);
185 fprintf (fp,
" \t%d\n",*sfint32);
188 case FIELDTYPE_MFInt32:
189 case FIELDTYPE_MFBool:
193 for (i=0; i<mfint32->n; i++) { fprintf (fp,
" %d,",mfint32->p[i]); }
197 case FIELDTYPE_SFVec2f:
200 for (i=0; i<2; i++) { fprintf (fp,
"%4.3f ",sfvec2f->c[i]); }
203 case FIELDTYPE_MFVec2f:
207 for (i=0; i<mfvec2f->n; i++)
208 { fprintf (fp,
"[%4.3f, %4.3f],",mfvec2f->p[i].c[0], mfvec2f->p[i].c[1]); }
212 case FIELDTYPE_SFVec2d:
215 for (i=0; i<2; i++) { fprintf (fp,
"%4.3f, ",sfvec2d->c[i]); }
218 case FIELDTYPE_MFVec2d:
222 for (i=0; i<mfvec2d->n; i++)
223 { fprintf (fp,
"[%4.3f, %4.3f], ",mfvec2d->p[i].c[0], mfvec2d->p[i].c[1]); }
227 case FIELDTYPE_SFVec3f:
228 case FIELDTYPE_SFColor:
231 for (i=0; i<3; i++) { fprintf (fp,
"%4.3f ",sfvec3f->c[i]); }
234 case FIELDTYPE_MFVec3f:
235 case FIELDTYPE_MFColor:
239 for (i=0; i<mfvec3f->n; i++)
240 { fprintf (fp,
"[%4.3f, %4.3f, %4.3f],",mfvec3f->p[i].c[0], mfvec3f->p[i].c[1],mfvec3f->p[i].c[2]); }
244 case FIELDTYPE_SFVec3d:
247 for (i=0; i<3; i++) { fprintf (fp,
"%4.3f ",sfvec3d->c[i]); }
250 case FIELDTYPE_MFVec3d:
254 for (i=0; i<mfvec3d->n; i++)
255 { fprintf (fp,
"[%4.3f, %4.3f, %4.3f],",mfvec3d->p[i].c[0], mfvec3d->p[i].c[1],mfvec3d->p[i].c[2]); }
259 case FIELDTYPE_SFVec4f:
260 case FIELDTYPE_SFColorRGBA:
261 case FIELDTYPE_SFRotation:
264 for (i=0; i<4; i++) { fprintf (fp,
"%4.3f ",sfrot->c[i]); }
267 case FIELDTYPE_MFVec4f:
268 case FIELDTYPE_MFColorRGBA:
269 case FIELDTYPE_MFRotation:
273 for (i=0; i<mfrgba->n; i++)
274 { fprintf (fp,
"[%4.3f, %4.3f, %4.3f, %4.3f]\n",mfrgba->p[i].c[0], mfrgba->p[i].c[1],mfrgba->p[i].c[2],mfrgba->p[i].c[3]); }
278 case FIELDTYPE_SFVec4d:
281 for (i=0; i<4; i++) { fprintf (fp,
"%4.3f ",sfvec4d->c[i]); }
284 case FIELDTYPE_MFVec4d:
288 for (i=0; i<mfvec4d->n; i++)
289 { fprintf (fp,
"[%4.3f, %4.3f, %4.3f, %4.3f],",mfvec4d->p[i].c[0], mfvec4d->p[i].c[1],mfvec4d->p[i].c[2],mfvec4d->p[i].c[3]); }
293 case FIELDTYPE_SFMatrix3f:
296 fprintf (fp,
" [%4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f ]\n",
297 sfmat3f->c[0],sfmat3f->c[1],sfmat3f->c[2],
298 sfmat3f->c[3],sfmat3f->c[4],sfmat3f->c[5],
299 sfmat3f->c[6],sfmat3f->c[7],sfmat3f->c[8]);
302 case FIELDTYPE_MFMatrix3f:
306 for (i=0; i<mfmat3f->n; i++) {
307 fprintf (fp,
"[%4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f ],",
308 mfmat3f->p[i].c[0],mfmat3f->p[i].c[1],mfmat3f->p[i].c[2],
309 mfmat3f->p[i].c[3],mfmat3f->p[i].c[4],mfmat3f->p[i].c[5],
310 mfmat3f->p[i].c[6],mfmat3f->p[i].c[7],mfmat3f->p[i].c[8]); }
314 case FIELDTYPE_SFMatrix3d:
317 fprintf (fp,
" [%4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f ]",
318 sfmat3d->c[0],sfmat3d->c[1],sfmat3d->c[2],
319 sfmat3d->c[3],sfmat3d->c[4],sfmat3d->c[5],
320 sfmat3d->c[6],sfmat3d->c[7],sfmat3d->c[8]);
323 case FIELDTYPE_MFMatrix3d:
327 for (i=0; i<mfmat3d->n; i++) {
328 fprintf (fp,
" %d: \t[%4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f ]\n",i,
329 mfmat3d->p[i].c[0],mfmat3d->p[i].c[1],mfmat3d->p[i].c[2],
330 mfmat3d->p[i].c[3],mfmat3d->p[i].c[4],mfmat3d->p[i].c[5],
331 mfmat3d->p[i].c[6],mfmat3d->p[i].c[7],mfmat3d->p[i].c[8]); }
334 case FIELDTYPE_SFMatrix4f:
337 fprintf (fp,
" \t[%4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f ]\n",
338 sfmat4f->c[0],sfmat4f->c[1],sfmat4f->c[2],sfmat4f->c[3],
339 sfmat4f->c[4],sfmat4f->c[5],sfmat4f->c[6],sfmat4f->c[7],
340 sfmat4f->c[8],sfmat4f->c[9],sfmat4f->c[10],sfmat4f->c[11],
341 sfmat4f->c[12],sfmat4f->c[13],sfmat4f->c[14],sfmat4f->c[15]);
344 case FIELDTYPE_MFMatrix4f:
348 for (i=0; i<mfmat4f->n; i++) {
349 fprintf (fp,
"[%4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f ],",
350 mfmat4f->p[i].c[0],mfmat4f->p[i].c[1],mfmat4f->p[i].c[2],mfmat4f->p[i].c[3],
351 mfmat4f->p[i].c[4],mfmat4f->p[i].c[5],mfmat4f->p[i].c[6],mfmat4f->p[i].c[7],
352 mfmat4f->p[i].c[8],mfmat4f->p[i].c[9],mfmat4f->p[i].c[10],mfmat4f->p[i].c[11],
353 mfmat4f->p[i].c[12],mfmat4f->p[i].c[13],mfmat4f->p[i].c[14],mfmat4f->p[i].c[15]); }
357 case FIELDTYPE_SFMatrix4d:
360 fprintf (fp,
" [%4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f ]",
361 sfmat4d->c[0],sfmat4d->c[1],sfmat4d->c[2],sfmat4d->c[3],
362 sfmat4d->c[4],sfmat4d->c[5],sfmat4d->c[6],sfmat4d->c[7],
363 sfmat4d->c[8],sfmat4d->c[9],sfmat4d->c[10],sfmat4d->c[11],
364 sfmat4d->c[12],sfmat4d->c[13],sfmat4d->c[14],sfmat4d->c[15]);
367 case FIELDTYPE_MFMatrix4d:
371 for (i=0; i<mfmat4d->n; i++) {
372 fprintf (fp,
"[%4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f ],",
373 mfmat4d->p[i].c[0],mfmat4d->p[i].c[1],mfmat4d->p[i].c[2],mfmat4d->p[i].c[3],
374 mfmat4d->p[i].c[4],mfmat4d->p[i].c[5],mfmat4d->p[i].c[6],mfmat4d->p[i].c[7],
375 mfmat4d->p[i].c[8],mfmat4d->p[i].c[9],mfmat4d->p[i].c[10],mfmat4d->p[i].c[11],
376 mfmat4d->p[i].c[12],mfmat4d->p[i].c[13],mfmat4d->p[i].c[14],mfmat4d->p[i].c[15]); }
381 case FIELDTYPE_SFImage:
383 fprintf(fp,
" %p ",(
void *)value);
388 void dump_scene(FILE *fp,
int level,
struct X3D_Node* node);
389 void dump_scene2(FILE *fp,
int level,
struct X3D_Node* node,
int recurse,
Stack *DEFedNodes);
392 void print_field(FILE *fp,
int level,
int typeIndex,
const char* fieldName,
union anyVrml* value,
Stack* DEFedNodes)
395 #define spacer for (lc=0; lc<level; lc++) fprintf (fp," ");
399 case FIELDTYPE_FreeWRLPTR:
401 fprintf(fp,
" %p \n",(
void *)value);
404 case FIELDTYPE_SFNode:
408 dore = doRecurse(fieldName);
409 fprintf (fp,
":\n"); dump_scene2(fp,level+1,*sfnode,dore,DEFedNodes);
412 case FIELDTYPE_MFNode:
416 dore = doRecurse(fieldName);
419 for(j=0;j<mfnode->n;j++)
420 dump_scene2(fp,level+1,mfnode->p[j],dore,DEFedNodes);
423 case FIELDTYPE_SFString:
426 fprintf (fp,
" \t%s\n",(*sfstring)->strptr);
429 case FIELDTYPE_MFString:
432 fprintf (fp,
" : \n");
433 for (i=0; i<mfstring->n; i++) { spacer fprintf (fp,
" %d: \t%s\n",i,mfstring->p[i]->strptr); }
436 case FIELDTYPE_SFFloat:
438 float *flt = (
float*)value;
439 fprintf (fp,
" \t%4.3f\n",*flt);
442 case FIELDTYPE_MFFloat:
446 for (i=0; i<mffloat->n; i++) { spacer fprintf (fp,
" %d: \t%4.3f\n",i,mffloat->p[i]); }
449 case FIELDTYPE_SFTime:
450 case FIELDTYPE_SFDouble:
452 double *sftime = (
double*)value;
453 fprintf (fp,
" \t%4.3f\n",*sftime);
456 case FIELDTYPE_MFTime:
457 case FIELDTYPE_MFDouble:
461 for (i=0; i<mfdouble->n; i++) { spacer fprintf (fp,
" %d: \t%4.3f\n",i,mfdouble->p[i]); }
464 case FIELDTYPE_SFInt32:
465 case FIELDTYPE_SFBool:
467 int *sfint32 = (
int*)(value);
468 fprintf (fp,
" \t%d\n",*sfint32);
471 case FIELDTYPE_MFInt32:
472 case FIELDTYPE_MFBool:
476 for (i=0; i<mfint32->n; i++) { spacer fprintf (fp,
" %d: \t%d\n",i,mfint32->p[i]); }
479 case FIELDTYPE_SFVec2f:
483 for (i=0; i<2; i++) { fprintf (fp,
"%4.3f ",sfvec2f->c[i]); }
487 case FIELDTYPE_MFVec2f:
491 for (i=0; i<mfvec2f->n; i++)
492 { spacer fprintf (fp,
" %d: \t[%4.3f, %4.3f]\n",i,mfvec2f->p[i].c[0], mfvec2f->p[i].c[1]); }
495 case FIELDTYPE_SFVec2d:
499 for (i=0; i<2; i++) { fprintf (fp,
"%4.3f ",sfvec2d->c[i]); }
503 case FIELDTYPE_MFVec2d:
507 for (i=0; i<mfvec2d->n; i++)
508 { spacer fprintf (fp,
" %d: \t[%4.3f, %4.3f]\n",i,mfvec2d->p[i].c[0], mfvec2d->p[i].c[1]); }
511 case FIELDTYPE_SFVec3f:
512 case FIELDTYPE_SFColor:
516 for (i=0; i<3; i++) { fprintf (fp,
"%4.3f ",sfvec3f->c[i]); }
520 case FIELDTYPE_MFVec3f:
521 case FIELDTYPE_MFColor:
525 for (i=0; i<mfvec3f->n; i++)
526 { spacer fprintf (fp,
" %d: \t[%4.3f, %4.3f, %4.3f]\n",i,mfvec3f->p[i].c[0], mfvec3f->p[i].c[1],mfvec3f->p[i].c[2]); }
529 case FIELDTYPE_SFVec3d:
533 for (i=0; i<3; i++) { fprintf (fp,
"%4.3f ",sfvec3d->c[i]); }
537 case FIELDTYPE_MFVec3d:
541 for (i=0; i<mfvec3d->n; i++)
542 { spacer fprintf (fp,
" %d: \t[%4.3f, %4.3f, %4.3f]\n",i,mfvec3d->p[i].c[0], mfvec3d->p[i].c[1],mfvec3d->p[i].c[2]); }
545 case FIELDTYPE_SFVec4f:
546 case FIELDTYPE_SFColorRGBA:
547 case FIELDTYPE_SFRotation:
551 for (i=0; i<4; i++) { fprintf (fp,
"%4.3f ",sfrot->c[i]); }
555 case FIELDTYPE_MFVec4f:
556 case FIELDTYPE_MFColorRGBA:
557 case FIELDTYPE_MFRotation:
561 for (i=0; i<mfrgba->n; i++)
562 { spacer fprintf (fp,
" %d: \t[%4.3f, %4.3f, %4.3f, %4.3f]\n",i,mfrgba->p[i].c[0], mfrgba->p[i].c[1],mfrgba->p[i].c[2],mfrgba->p[i].c[3]); }
565 case FIELDTYPE_SFVec4d:
569 for (i=0; i<4; i++) { fprintf (fp,
"%4.3f ",sfvec4d->c[i]); }
573 case FIELDTYPE_MFVec4d:
577 for (i=0; i<mfvec4d->n; i++)
578 { spacer fprintf (fp,
" %d: \t[%4.3f, %4.3f, %4.3f, %4.3f]\n",i,mfvec4d->p[i].c[0], mfvec4d->p[i].c[1],mfvec4d->p[i].c[2],mfvec4d->p[i].c[3]); }
581 case FIELDTYPE_SFMatrix3f:
584 spacer fprintf (fp,
" \t[%4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f ]\n",
585 sfmat3f->c[0],sfmat3f->c[1],sfmat3f->c[2],
586 sfmat3f->c[3],sfmat3f->c[4],sfmat3f->c[5],
587 sfmat3f->c[6],sfmat3f->c[7],sfmat3f->c[8]);
590 case FIELDTYPE_MFMatrix3f:
594 for (i=0; i<mfmat3f->n; i++) {
595 spacer fprintf (fp,
" %d: \t[%4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f ]\n",i,
596 mfmat3f->p[i].c[0],mfmat3f->p[i].c[1],mfmat3f->p[i].c[2],
597 mfmat3f->p[i].c[3],mfmat3f->p[i].c[4],mfmat3f->p[i].c[5],
598 mfmat3f->p[i].c[6],mfmat3f->p[i].c[7],mfmat3f->p[i].c[8]); }
601 case FIELDTYPE_SFMatrix3d:
604 spacer fprintf (fp,
" \t[%4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f ]\n",
605 sfmat3d->c[0],sfmat3d->c[1],sfmat3d->c[2],
606 sfmat3d->c[3],sfmat3d->c[4],sfmat3d->c[5],
607 sfmat3d->c[6],sfmat3d->c[7],sfmat3d->c[8]);
610 case FIELDTYPE_MFMatrix3d:
614 for (i=0; i<mfmat3d->n; i++) {
615 spacer fprintf (fp,
" %d: \t[%4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f ]\n",i,
616 mfmat3d->p[i].c[0],mfmat3d->p[i].c[1],mfmat3d->p[i].c[2],
617 mfmat3d->p[i].c[3],mfmat3d->p[i].c[4],mfmat3d->p[i].c[5],
618 mfmat3d->p[i].c[6],mfmat3d->p[i].c[7],mfmat3d->p[i].c[8]); }
621 case FIELDTYPE_SFMatrix4f:
624 fprintf (fp,
" \t[%4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f ]\n",
625 sfmat4f->c[0],sfmat4f->c[1],sfmat4f->c[2],sfmat4f->c[3],
626 sfmat4f->c[4],sfmat4f->c[5],sfmat4f->c[6],sfmat4f->c[7],
627 sfmat4f->c[8],sfmat4f->c[9],sfmat4f->c[10],sfmat4f->c[11],
628 sfmat4f->c[12],sfmat4f->c[13],sfmat4f->c[14],sfmat4f->c[15]);
631 case FIELDTYPE_MFMatrix4f:
635 for (i=0; i<mfmat4f->n; i++) {
637 fprintf (fp,
" %d: \t[%4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f ]\n",i,
638 mfmat4f->p[i].c[0],mfmat4f->p[i].c[1],mfmat4f->p[i].c[2],mfmat4f->p[i].c[3],
639 mfmat4f->p[i].c[4],mfmat4f->p[i].c[5],mfmat4f->p[i].c[6],mfmat4f->p[i].c[7],
640 mfmat4f->p[i].c[8],mfmat4f->p[i].c[9],mfmat4f->p[i].c[10],mfmat4f->p[i].c[11],
641 mfmat4f->p[i].c[12],mfmat4f->p[i].c[13],mfmat4f->p[i].c[14],mfmat4f->p[i].c[15]); }
644 case FIELDTYPE_SFMatrix4d:
647 fprintf (fp,
" \t[%4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f ]\n",
648 sfmat4d->c[0],sfmat4d->c[1],sfmat4d->c[2],sfmat4d->c[3],
649 sfmat4d->c[4],sfmat4d->c[5],sfmat4d->c[6],sfmat4d->c[7],
650 sfmat4d->c[8],sfmat4d->c[9],sfmat4d->c[10],sfmat4d->c[11],
651 sfmat4d->c[12],sfmat4d->c[13],sfmat4d->c[14],sfmat4d->c[15]);
654 case FIELDTYPE_MFMatrix4d:
658 for (i=0; i<mfmat4d->n; i++) {
660 fprintf (fp,
" %d: \t[%4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f, %4.3f ]\n",i,
661 mfmat4d->p[i].c[0],mfmat4d->p[i].c[1],mfmat4d->p[i].c[2],mfmat4d->p[i].c[3],
662 mfmat4d->p[i].c[4],mfmat4d->p[i].c[5],mfmat4d->p[i].c[6],mfmat4d->p[i].c[7],
663 mfmat4d->p[i].c[8],mfmat4d->p[i].c[9],mfmat4d->p[i].c[10],mfmat4d->p[i].c[11],
664 mfmat4d->p[i].c[12],mfmat4d->p[i].c[13],mfmat4d->p[i].c[14],mfmat4d->p[i].c[15]); }
668 case FIELDTYPE_SFImage:
670 fprintf(fp,
" %p \n",(
void *)value);
684 void dump_scene2(FILE *fp,
int level,
struct X3D_Node* node,
int recurse,
Stack *DEFedNodes) {
685 #define spacer for (lc=0; lc<level; lc++) fprintf (fp," ");
690 typedef struct field_info{
703 if (fileno(fp) == fileno(stdout)) { allFields = TRUE; }
else { allFields = FALSE; }
705 Boolean allFields = TRUE;
708 if (node==NULL)
return;
711 if (level == 0) fprintf (fp,
"starting dump_scene2\n");
712 nodeName = parser_getNameFromNode(node) ;
713 isDefed = isNodeDEFedYet(node,DEFedNodes);
714 spacer fprintf (fp,
"L%d: node (%p) (",level,node);
715 if(nodeName != NULL) {
717 fprintf(fp,
"USE %s",nodeName);
719 fprintf(fp,
"DEF %s",nodeName);
721 fprintf(fp,
") type %s\n",stringNodeType(node->_nodeType));
723 if(recurse && !isDefed)
725 vector_pushBack(
struct X3D_Node*, DEFedNodes, node);
726 offsets = (finfo)NODE_OFFSETS[node->_nodeType];
728 field = &offsets[ifield];
729 while( field->nameIndex > -1)
732 privat = FIELDNAMES[field->nameIndex][0] ==
'_';
733 privat = privat && strcmp(FIELDNAMES[field->nameIndex],
"__scriptObj");
734 privat = privat && strcmp(FIELDNAMES[field->nameIndex],
"__protoDef");
735 if(allFields || !privat)
738 fprintf(fp,
" %s",FIELDNAMES[field->nameIndex]);
739 fprintf(fp,
" (%s)",FIELDTYPES[field->typeIndex]);
740 if(node->_nodeType == NODE_Script && !strcmp(FIELDNAMES[field->nameIndex],
"__scriptObj") )
749 sp = *(
struct Shader_Script **)&((
char*)node)[field->offset];
750 fprintf(fp,
"loaded = %d\n",sp->loaded);
751 sfields = sp->fields;
753 for(k=0;k<sfields->n;k++)
758 fdecl = sfield->fieldDecl;
759 fieldName = fieldDecl_getShaderScriptName(fdecl);
760 fprintf(fp,
" %s",fieldName);
762 fprintf(fp,
" (%s)", stringFieldtypeType(fdecl->fieldType));
763 fprintf(fp,
" %s ",stringPROTOKeywordType(fdecl->PKWmode));
765 if(fdecl->PKWmode == PKW_initializeOnly)
766 print_field(fp,level,fdecl->fieldType,fieldName,&(sfield->value),DEFedNodes);
772 else if(node->_nodeType == NODE_Proto && !strcmp(FIELDNAMES[field->nameIndex],
"__protoDef") )
779 fprintf(fp,
" user fields:\n");
782 for(k=0; k!=vectorSize(pstruct->iface); ++k)
784 const char *fieldName;
787 fieldName = pfield->cname;
789 fprintf(fp,
" %p ",(
void*)pfield);
790 fprintf(fp,
" %s",fieldName);
791 fprintf(fp,
" (%s)", stringFieldtypeType(pfield->type));
792 fprintf(fp,
" %s ",stringPROTOKeywordType(pfield->mode));
794 if(pfield->mode == PKW_initializeOnly || pfield->mode == PKW_inputOutput)
795 print_field(fp,level,pfield->type,fieldName,&(pfield->defaultVal),DEFedNodes);
802 union anyVrml* any_except_PTR = (
union anyVrml*)&((
char*)node)[field->offset];
803 print_field(fp,level,field->typeIndex,FIELDNAMES[field->nameIndex],any_except_PTR,DEFedNodes);
807 field = &offsets[ifield];
811 spacer fprintf (fp,
"L%d end\n",level);
812 if (level == 0) fprintf (fp,
"ending dump_scene2\n");
816 void deep_copy2(
int iopt,
char* defname)
821 ConsoleMessage(
"in deep_copy2 - for copying a node and its fields\n");
822 ConsoleMessage(
"got iopt=%d defname=%s\n",iopt,defname);
823 if(iopt == 0)
return;
826 node = parser_getNodeFromName(defname);
830 node = (
struct X3D_Node*)rootNode();
834 sscanf(defname,
"%p",&node);
836 if( checkNode(node, NULL, 0) )
838 name2 = parser_getNameFromNode(node);
840 ConsoleMessage(
"You entered %s\n",name2);
842 ConsoleMessage(
"Node exists!\n");
844 ConsoleMessage(
"Node does not exist.\n");
848 void print_DEFed_node_names_and_pointers(FILE* fp)
850 int ind,j,jj,nstack,nvector;
853 struct Vector *curNameStackTop;
854 struct Vector *curNodeStackTop;
857 fprintf(fp,
"DEFedNodes ");
858 if(!globalParser)
return;
859 if(globalParser->DEFedNodes == NULL)
861 fprintf(fp,
" NULL\n");
864 nstack = globalParser->lexer->userNodeNames->n;
865 fprintf(fp,
" lexer namespace vectors = %d\n",nstack);
866 for(j=0;j<nstack;j++)
868 curNameStackTop = vector_get(
struct Vector *, globalParser->lexer->userNodeNames,j);
869 curNodeStackTop = vector_get(
struct Vector *, globalParser->DEFedNodes,j);
870 if(curNameStackTop && curNodeStackTop)
872 nvector = vectorSize(curNodeStackTop);
873 for(jj=0;jj<j;jj++) fprintf(fp,
" ");
874 fprintf(fp,
"vector %d name count = %d\n",j,nvector);
875 for (ind=0; ind < nvector; ind++)
877 for(jj=0;jj<j;jj++) fprintf(fp,
" ");
878 node = vector_get(
struct X3D_Node*,curNodeStackTop, ind);
879 name = vector_get(
char *,curNameStackTop, ind);
880 fprintf (fp,
"L%d: node (%p) name (%s) \n",jj,node,name);
885 char *findFIELDNAMESfromNodeOffset0(
struct X3D_Node *node,
int offset)
887 if( node->_nodeType != NODE_Script)
889 if( node->_nodeType == NODE_Proto )
897 if(offset < vectorSize(pstruct->iface))
900 pfield= vector_get(
struct ProtoFieldDecl*, pstruct->iface, offset);
902 return pfield->cname;
909 return (
char *)findFIELDNAMESfromNodeOffset(node,offset);
919 fields = myObj->fields;
921 return fieldDecl_getShaderScriptName(curField->fieldDecl);
925 char *findFIELDNAMES0(
struct X3D_Node *node,
int offset)
927 return findFIELDNAMESfromNodeOffset0(node,offset);
929 #include "../vrml_parser/CRoutes.h"
930 void print_routes_ready_to_register(FILE* fp);
931 void print_routes(FILE* fp)
942 print_routes_ready_to_register(fp);
943 numRoutes = getRoutesCount();
944 fprintf(fp,
"Number of Routes %d\n",numRoutes-2);
950 for (count = 1; count < (numRoutes-1); count++) {
951 getSpecificRoute (count,&fromNode, &fromOffset, &toNode, &toOffset);
952 fromName = parser_getNameFromNode(fromNode);
953 toName = parser_getNameFromNode(toNode);
955 fprintf (fp,
" %p %s.%s TO %p %s.%s \n",fromNode,fromName,
956 findFIELDNAMESfromNodeOffset0(fromNode,fromOffset),
958 findFIELDNAMESfromNodeOffset0(toNode,toOffset)
962 static struct consoleMenuState
965 void (*f)(
void*,
char*);
971 int consoleMenuActive()
973 return ConsoleMenuState.active;
975 void setConsoleMenu(
void *yourData,
char *prompt,
void (*callback),
char* dfault)
977 ConsoleMenuState.f = callback;
978 ConsoleMenuState.len = 0;
979 ConsoleMenuState.buf[0] =
'\0';
980 ConsoleMenuState.active = TRUE;
981 ConsoleMenuState.dfault = dfault;
982 ConsoleMenuState.yourData = yourData;
983 ConsoleMessage(prompt);
984 ConsoleMessage(
"[%s]:",dfault);
986 void deep_copy_defname(
void *myData,
char *defname)
989 ConsoleMessage(
"you entered defname: %s\n",defname);
990 memcpy(&iopt,myData,4);
991 deep_copy2(iopt,defname);
994 void deep_copy_option(
void* yourData,
char *opt)
997 ConsoleMessage(
"you chose option %s\n",opt);
998 sscanf(opt,
"%d",&iopt);
999 if(iopt == 0)
return;
1000 if(iopt == 1 || iopt == 3)
1002 void* myData = MALLOC(
void *, 4);
1003 memcpy(myData,&iopt,4);
1004 setConsoleMenu(myData,
"Enter DEFname or node address:", deep_copy_defname,
"");
1007 deep_copy2(iopt, NULL);
1009 void dump_scenegraph(
int method)
1013 dump_scene(stdout, 0, (
struct X3D_Node*) rootNode());
1014 else if(method == 2)
1017 dump_scene2(stdout, 0, (
struct X3D_Node*) rootNode(),1,DEFedNodes);
1018 deleteVector(
struct X3D_Node*,DEFedNodes);
1020 else if(method == 3)
1022 print_DEFed_node_names_and_pointers(stdout);
1024 else if(method == 4)
1026 print_routes(stdout);
1028 else if(method == 5)
1031 setConsoleMenu(NULL,
"0. Exit 1.DEFname 2.ROOTNODE 3.node address", deep_copy_option,
"0");
1038 void register_node_gc(
void *node,
void *p);
1039 void unregister_node_gc(
void *node,
void *p);
1040 void free_registered_node_gc(
void* node);
1042 void register_node_gc(
void *node,
void *p){
1044 if(!_node->_gc) _node->_gc = newVector(
void*,1);
1045 vector_pushBack(
void*,_node->_gc,p);
1047 void unregister_node_gc(
void *node,
void *p){
1053 if(!_node->_gc)
return;
1055 v = (
struct Vector*)_node->_gc;
1056 for(i=0;i<v->n;i++){
1057 p0 = vector_get(
void*,v,i);
1059 vector_set(
void*,v,i,NULL);
1064 void free_registered_node_gc(
void* node){
1070 for(i=0;i<v->n;i++){
1071 p = vector_get(
void *,v,i);
1074 deleteVector(
void*,_node->_gc);
1082 #if defined(DISABLER) || defined(DISABLER_MALLOC)
1085 #define WRAP_MALLOC 1
1088 int DROIDDEBUG(
const char*pFmtStr, ...);
1089 #define printf DROIDDEBUG
1098 #if defined(WRAP_MALLOC) || defined(DEBUG_MALLOC)
1100 #define FWL_NOT_FOUND_IN_MEM_TABLE -1
1102 void __free_memtable_elem(
void *ptr);
1103 void __free_memtable_elem_with_data(
void *ptr);
1104 int __match_memtable_elem(
void *elem1,
void *elem2);
1106 typedef struct fwl_memtable_elem
1111 } fwl_memtable_elem;
1114 static ttglobal sLastSeenGlobal = NULL;
1116 void __freeWholeMemTable(
ttglobal gg)
1118 if (gg->__memTable != NULL)
1120 gg->__memTable->free = &__free_memtable_elem_with_data;
1121 dbl_list_destroy(gg->__memTable);
1122 gg->__memTable = NULL;
1126 int __removeFromMemTable(
ttglobal gg,
void *ptr,
char *file,
int line)
1128 int retVal = FWL_NOT_FOUND_IN_MEM_TABLE;
1129 if (gg->__memTable != NULL)
1131 fwl_memtable_elem searchedElem;
1132 searchedElem.ptr = ptr;
1133 dbl_list_node_t *node = dbl_list_find(gg->__memTable, &searchedElem);
1137 dbl_list_remove(gg->__memTable, node);
1141 printf (
"freewrlFree - did not find 0x%016llx at %s:%d\n", (
unsigned long long)ptr,file,line);
1148 void __reserveInMemTable(
ttglobal gg,
void *ptr,
char *file,
int line)
1150 if (gg->__memTable != NULL)
1152 fwl_memtable_elem searchedElem;
1153 searchedElem.ptr = ptr;
1154 dbl_list_node_t *node = dbl_list_find(gg->__memTable, &searchedElem);
1157 fwl_memtable_elem *foundElem = (fwl_memtable_elem *)node->val;
1159 printf (
"freewrl__ReserveInMemTable - ptr already in the table 0x%016llx at %s:%d, added at %s:%d\n", (
unsigned long long)ptr, file, line, foundElem->fileName, foundElem->lineNubmer);
1164 fwl_memtable_elem *newElem = malloc(
sizeof(fwl_memtable_elem));
1165 newElem->fileName = file;
1166 newElem->lineNubmer = line;
1168 dbl_list_rpush(gg->__memTable, dbl_list_node_new(newElem));
1173 #define LOCK_GLOBAL_MEMORYTABLE if (tg) pthread_mutex_lock(&tg->__memTableGlobalLock);
1174 #define UNLOCK_GLOBAL_MEMORYTABLE if (tg) pthread_mutex_unlock(&tg->__memTableGlobalLock);
1181 sLastSeenGlobal = tg;
1185 tg = sLastSeenGlobal;
1191 void freewrlInitMemTable()
1193 ttglobal tg = freewrlGetActualGlobal();
1196 pthread_mutex_init(&(tg->__memTableGlobalLock), NULL);
1198 LOCK_GLOBAL_MEMORYTABLE
1200 if (tg && !tg->__memTable_CheckInit) {
1202 tg->__memTable = dbl_list_new();
1203 tg->__memTable->free = &__free_memtable_elem;
1204 tg->__memTable->match = &__match_memtable_elem;
1205 tg->__memTable_CheckInit = TRUE;
1208 UNLOCK_GLOBAL_MEMORYTABLE
1211 void __free_memtable_elem_with_data(
void *ptr)
1213 fwl_memtable_elem *elem = (fwl_memtable_elem *)ptr;
1215 printf (
"freewrl MemTable disposing ptr 0x%016llx\n", (
unsigned long long)elem->ptr);
1221 void __free_memtable_elem(
void *ptr)
1226 int __match_memtable_elem(
void *elem1,
void *elem2)
1228 return ((fwl_memtable_elem *)elem1)->ptr == ((fwl_memtable_elem *)elem2)->ptr;
1231 void freewrlDisposeMemTable()
1233 ttglobal tg = freewrlGetActualGlobal();
1236 pthread_mutex_destroy(&(tg->__memTableGlobalLock));
1237 if (sLastSeenGlobal == tg)
1239 sLastSeenGlobal = NULL;
1244 void freewrlFree(
int line,
char *file,
void *a)
1246 ttglobal tg = freewrlGetActualGlobal();
1247 LOCK_GLOBAL_MEMORYTABLE
1251 printf (
"freewrlFree 0x%016llx xfree at %s:%d\n", (
unsigned long long)a, file,line);
1254 __removeFromMemTable(tg, a,file,line);
1257 UNLOCK_GLOBAL_MEMORYTABLE
1261 void scanMallocTableOnQuit()
1263 ttglobal tg = freewrlGetActualGlobal();
1264 LOCK_GLOBAL_MEMORYTABLE
1267 dbl_list_iterator_t *it = dbl_list_iterator_new(tg->__memTable, LIST_HEAD);
1268 dbl_list_node_t *node;
1269 while ((node = dbl_list_iterator_next(it))) {
1270 fwl_memtable_elem *elem = ((fwl_memtable_elem *)node->val);
1271 printf (
"unfreed memory %016llx created at %s:%d \n", (
unsigned long long)elem->ptr, elem->fileName, elem->lineNubmer);
1273 dbl_list_iterator_destroy(it);
1275 UNLOCK_GLOBAL_MEMORYTABLE
1278 void freewrlSetShouldRegisterAllocation(
bool shouldRegisterAllocation)
1280 ttglobal tg = freewrlGetActualGlobal();
1281 LOCK_GLOBAL_MEMORYTABLE
1284 tg->__memTable_ShouldRegisterAllocation = shouldRegisterAllocation;
1286 UNLOCK_GLOBAL_MEMORYTABLE
1289 bool freewrlIsRegisteringAllocation()
1291 ttglobal tg = freewrlGetActualGlobal();
1295 return tg->__memTable_ShouldRegisterAllocation;
1301 void freewrlFreeAllRegisteredAllocations()
1303 ttglobal tg = freewrlGetActualGlobal();
1304 LOCK_GLOBAL_MEMORYTABLE
1307 __freeWholeMemTable(tg);
1309 UNLOCK_GLOBAL_MEMORYTABLE
1315 void *freewrlMalloc(
int line,
char *file,
size_t sz,
int zeroData)
1319 ttglobal tg = freewrlGetActualGlobal();
1320 LOCK_GLOBAL_MEMORYTABLE
1323 if (zeroData) bzero (rv, sz);
1329 sprintf (myline,
"MALLOC PROBLEM - out of memory at %s:%d for %zu",file,line,sz);
1330 outOfMemory (myline);
1333 printf (
"freewrlMalloc 0x%016llx size %zu at %s:%d\n", (
unsigned long long)rv,sz,file,line);
1336 if (tg && tg->__memTable_ShouldRegisterAllocation)
1338 __reserveInMemTable(tg, rv,file,line);
1341 UNLOCK_GLOBAL_MEMORYTABLE
1346 void *freewrlRealloc(
int line,
char *file,
void *ptr,
size_t size)
1350 ttglobal tg = freewrlGetActualGlobal();
1351 LOCK_GLOBAL_MEMORYTABLE
1354 rv = realloc (ptr,size);
1362 sprintf (myline,
"REALLOC PROBLEM - out of memory at %s:%d size %zu",file,line,size);
1363 outOfMemory (myline);
1367 printf (
"freewrlRealloc 0x%016llx to 0x%016llx size %zu at %s:%d\n", (
unsigned long long)ptr, (
unsigned long long)rv, size, file, line);
1375 result = __removeFromMemTable(tg, ptr,file,line);
1377 if (result != FWL_NOT_FOUND_IN_MEM_TABLE)
1379 if (tg->__memTable_ShouldRegisterAllocation)
1381 __reserveInMemTable(tg, rv,file,line);
1386 printf (
"0x%016llx FOR REALLOC NOT FOUND for size %zu at %s:%d\n", (
unsigned long long)ptr,size,file,line);
1390 UNLOCK_GLOBAL_MEMORYTABLE
1395 void *freewrlStrdup (
int line,
char *file,
const char *str)
1399 ttglobal tg = freewrlGetActualGlobal();
1400 LOCK_GLOBAL_MEMORYTABLE
1404 printf(
"freewrlStrdup 0x%016llx, at line %d file %s\n",(
unsigned long long)rv, line,file);
1408 sprintf (myline,
"STRDUP PROBLEM - out of memory at %s:%d ",file,line);
1409 outOfMemory (myline);
1413 if (tg && tg->__memTable_ShouldRegisterAllocation)
1415 __reserveInMemTable(tg, rv,file,line);
1417 UNLOCK_GLOBAL_MEMORYTABLE
1421 void *freewrlStrndup (
int line,
char *file,
const char *str,
size_t n)
1424 ttglobal tg = freewrlGetActualGlobal();
1425 LOCK_GLOBAL_MEMORYTABLE
1427 rv = strndup (str, n);
1430 printf(
"freewrlStrndup 0x%016llx count at line %d file %s\n", (
unsigned long long)rv, line,file);
1434 sprintf (myline,
"STRNDUP PROBLEM - out of memory at %s:%d ",file,line);
1435 outOfMemory (myline);
1439 if (tg && tg->__memTable_ShouldRegisterAllocation)
1441 __reserveInMemTable(tg, rv,file,line);
1443 UNLOCK_GLOBAL_MEMORYTABLE
1467 static int _noisy = 0;
1469 #define MAXMALLOCSTOKEEP 100000
1470 static int mcheckinit = FALSE;
1471 static void* mcheck[MAXMALLOCSTOKEEP];
1472 static char* mplace[MAXMALLOCSTOKEEP];
1473 static int mlineno[MAXMALLOCSTOKEEP];
1474 static size_t msize[MAXMALLOCSTOKEEP];
1477 static mcheck_init(){
1479 for (mcount=0; mcount < MAXMALLOCSTOKEEP; mcount++) {
1480 mcheck[mcount] = NULL;
1481 mplace[mcount] = NULL;
1482 mlineno[mcount] = 0;
1489 void FREETABLE(
void *a,
char *file,
int line) {
1490 LOCK_GLOBAL_MEMORYTABLE
1492 while ((mcount<(MAXMALLOCSTOKEEP-1)) && (mcheck[mcount]!=a)) mcount++;
1493 if (mcheck[mcount]!=a) {
1494 printf (
"freewrlFree - did not find %p at %s:%d\n",a,file,line);
1495 printf(
"mcount = %d\n",mcount);
1500 mcheck[mcount] = NULL;
1501 mlineno[mcount] = 0;
1502 if (mplace[mcount]!=NULL) free(mplace[mcount]);
1503 mplace[mcount]=NULL;
1505 UNLOCK_GLOBAL_MEMORYTABLE
1508 void RESERVETABLE(
void *a,
char *file,
int line,
int size) {
1509 LOCK_GLOBAL_MEMORYTABLE
1511 while ((mcount<(MAXMALLOCSTOKEEP-1)) && (mcheck[mcount]!=NULL)) mcount++;
1512 if (mcheck[mcount]!=NULL) {
1513 printf (
"freewrlMalloc - out of malloc check store\n");
1514 printf(
"mcount=%d\n",mcount);
1518 mlineno[mcount] = line;
1519 mplace[mcount] = strdup(file);
1520 msize[mcount] = size;
1522 UNLOCK_GLOBAL_MEMORYTABLE
1525 void freewrlFree(
int line,
char *file,
void *a)
1528 if(_noisy) printf (
"freewrlFree %p xfree at %s:%d\n",a,file,line);
1530 FREETABLE(a,file,line);
1534 void scanMallocTableOnQuit_old()
1536 for (mcount=0; mcount<MAXMALLOCSTOKEEP;mcount++) {
1537 if (mcheck[mcount]!=NULL) {
1538 printf (
"unfreed memory %p created at %s:%d \n",mcheck[mcount], mplace[mcount],mlineno[mcount]);
1542 typedef struct malloc_location {
1550 #define alloca _alloca
1552 int comp_count (
const void * elem1,
const void * elem2)
1554 malloc_location *e1, *e2;
1555 e1 = (malloc_location*)elem1;
1556 e2 = (malloc_location*)elem2;
1557 return e1->count < e2->count ? -1 : e1->count > e2->count ? 1 : 0;
1559 int comp_size (
const void * elem1,
const void * elem2)
1561 malloc_location *e1, *e2;
1562 e1 = (malloc_location*)elem1;
1563 e2 = (malloc_location*)elem2;
1564 return e1->size < e2->size ? -1 : e1->size > e2->size ? 1 : 0;
1566 int comp_file (
const void * elem1,
const void * elem2)
1568 malloc_location *e1, *e2;
1569 e1 = (malloc_location*)elem1;
1570 e2 = (malloc_location*)elem2;
1571 return strcmp(e1->fname,e2->fname);
1573 int comp_line (
const void * elem1,
const void * elem2)
1575 malloc_location *e1, *e2;
1576 e1 = (malloc_location*)elem1;
1577 e2 = (malloc_location*)elem2;
1578 return e1->line < e2->line ? -1 : e1->line > e2->line ? 1 : 0;
1580 int comp_fileline (
const void * elem1,
const void * elem2)
1583 iret = comp_file(elem1,elem2);
1585 iret = comp_line(elem1,elem2);
1588 void scanForVectorTypes(){
1589 for (mcount=0; mcount<MAXMALLOCSTOKEEP;mcount++) {
1590 if (mcheck[mcount]!=NULL) {
1591 if(mlineno[mcount]==5873){
1594 printf(
"!%d!",v->n);
1599 void scanForFieldTypes(){
1600 for (mcount=0; mcount<MAXMALLOCSTOKEEP;mcount++) {
1601 if (mcheck[mcount]!=NULL) {
1602 if(mlineno[mcount]==105){
1608 printf(
"#%s#",us->strptr);
1614 void scanForCstringTypes(){
1615 for (mcount=0; mcount<MAXMALLOCSTOKEEP;mcount++) {
1616 if (mcheck[mcount]!=NULL) {
1617 if(mlineno[mcount]==456 || mlineno[mcount]==117){
1618 char *s = (
char*)mcheck[mcount];
1624 void scanMallocTableOnQuit()
1630 scanForFieldTypes();
1632 malloc_location *mlocs = malloc(
sizeof(malloc_location)*MAXMALLOCSTOKEEP);
1633 memset(mlocs,0,
sizeof(malloc_location)*MAXMALLOCSTOKEEP);
1635 for (mcount=0; mcount<MAXMALLOCSTOKEEP;mcount++) {
1636 if (mcheck[mcount]!=NULL) {
1639 for(j=0;j<nlocs;j++){
1642 file = mplace[mcount];
1643 line = mlineno[mcount];
1644 mfile = mlocs[j].fname;
1645 mline = mlocs[j].line;
1647 printf(
"line %d",line);
1648 if(mfile) printf(
"mfile=%s",mfile);
1651 printf(
"line %d",line);
1652 if(file) printf(
"file=%s",file);
1655 if(!strcmp(file,mfile) && (line == mline) ){
1657 mlocs[j].size += msize[mcount];
1663 mlocs[nlocs].count = 1;
1664 mlocs[nlocs].fname = mplace[mcount];
1666 printf(
"adding null place\n");
1667 mlocs[nlocs].line = mlineno[mcount];
1668 mlocs[nlocs].size = msize[mcount];
1674 if(1) qsort(mlocs,nlocs,
sizeof(malloc_location),comp_fileline);
1675 if(0) qsort(mlocs,nlocs,
sizeof(malloc_location),comp_line);
1676 if(0) qsort(mlocs,nlocs,
sizeof(malloc_location),comp_file);
1677 if(0) qsort(mlocs,nlocs,
sizeof(malloc_location),comp_count);
1678 if(0) qsort(mlocs,nlocs,
sizeof(malloc_location),comp_size);
1679 printf(
"unfreed:\n");
1680 printf(
"%5s %8s %4s %55s\n",
"count",
"size",
"line",
"file");
1682 for(j=0;j<nlocs;j++){
1683 printf(
"%5d %8d %4d %55s\n",mlocs[j].count,mlocs[j].size, mlocs[j].line,mlocs[j].fname);
1684 total += mlocs[j].size;
1686 printf(
"total bytes not freed %d\n",total);
1695 void *freewrlMalloc(
int line,
char *file,
size_t sz,
int zeroData)
1704 sprintf (myline,
"MALLOC PROBLEM - out of memory at %s:%d for %d",file,line,sz);
1705 outOfMemory (myline);
1707 if(_noisy)printf (
"%p malloc %d at %s:%d\n",rv,sz,file,line);
1710 RESERVETABLE(rv,file,line,sz);
1712 if (zeroData) bzero (rv, sz);
1716 void *freewrlRealloc (
int line,
char *file,
void *ptr,
size_t size)
1723 if(_noisy) printf (
"%p xfree (from realloc) at %s:%d\n",ptr,file,line);
1724 rv = realloc (ptr,size);
1727 sprintf (myline,
"REALLOC PROBLEM - out of memory at %s:%d size %d",file,line,size);
1728 outOfMemory (myline);
1735 FREETABLE(ptr,file,line);
1736 RESERVETABLE(rv,file,line,size);
1742 void *freewrlStrdup (
int line,
char *file,
char *str)
1747 if(_noisy) printf(
"freewrlStrdup, at line %d file %s\n",line,file);
1750 sprintf (myline,
"STRDUP PROBLEM - out of memory at %s:%d ",file,line);
1751 outOfMemory (myline);
1753 if(_noisy) printf (
"freewrlStrdup, before reservetable\n");
1756 RESERVETABLE(rv,file,line,strlen(str)+1);
1759 void *mallocn_debug(
int line,
char *file,
void *node,
size_t size){
1761 struct X3D_Node *_node = X3D_NODE(node);
1762 p = freewrlMalloc(line,file,size,FALSE);
1763 register_node_gc(node,p);
1766 void *reallocn_debug(
int line,
char *file,
void *node,
void *pold,
size_t newsize){
1768 struct X3D_Node *_node = X3D_NODE(node);
1769 unregister_node_gc(node,pold);
1770 p = freewrlRealloc(line,file,pold,newsize);
1771 register_node_gc(node,p);
1775 void *mallocn(
void *node,
size_t size){
1779 register_node_gc(node,p);
1782 void *reallocn(
void *node,
void *pold,
size_t newsize){
1785 unregister_node_gc(node,pold);
1786 p = realloc(pold,newsize);
1787 register_node_gc(node,p);