components/prboom/w_wad.c
// killough 4/17/98: add namespace tags
killough 4/17/98: add namespace tags
killough 4 / 17 / 98 : add namespace tags
static void W_CoalesceMarkedResource(const char *start_marker,
                                     const char *end_marker, int li_namespace)
{
  lumpinfo_t *marked = malloc(sizeof(lumpinfo_t) * numlumps);
  size_t i, num_marked = 0, num_unmarked = 0;
  int is_marked = 0, mark_end = 0;
  lumpinfo_t *lump = lumpinfo;
	volatile int p;
	int x;
  for (i=numlumps; i--; lump++) {
    if (IsMarker(start_marker, lump->name)) {
        if (!num_marked) {
            strncpy(marked->name, start_marker, 8);
            marked->size = 0;  
            marked->li_namespace = ns_global;        
            marked->wadfile = NULL;
            num_marked = 1;
          }
        is_marked = 1;                            
      } else if (IsMarker(end_marker, lump->name)) {
          mark_end = 1;                           
          is_marked = 0;                          
      } else if (is_marked)  {                           
            marked[num_marked] = *lump;
            marked[num_marked++].li_namespace = li_namespace;  
      } else {
          lumpinfo[num_unmarked]=*lump;       
			num_unmarked++;
	  }
	}
  memcpy(&lumpinfo[num_unmarked], marked, num_marked * sizeof(*marked));
  free(marked);                                   
  numlumps = num_unmarked + num_marked;           
  if (mark_end)                                   
    {
      lumpinfo[numlumps].size = 0;  
      lumpinfo[numlumps].wadfile = NULL;
      lumpinfo[numlumps].li_namespace = ns_global;   
      strncpy(lumpinfo[numlumps++].name, end_marker, 8);
    }
}
static void W_CoalesceMarkedResource ( const char * start_marker , const char * end_marker , int li_namespace ) { lumpinfo_t * marked = malloc ( sizeof ( lumpinfo_t ) * numlumps ) ; size_t i , num_marked = 0 , num_unmarked = 0 ; int is_marked = 0 , mark_end = 0 ; lumpinfo_t * lump = lumpinfo ; volatile int p ; int x ; for ( i = numlumps ; i -- ; lump ++ ) { if ( IsMarker ( start_marker , lump -> name ) ) { if ( ! num_marked ) { strncpy ( marked -> name , start_marker , 8 ) ; marked -> size = 0 ; marked -> li_namespace = ns_global ; marked -> wadfile = NULL ; num_marked = 1 ; } is_marked = 1 ; } else if ( IsMarker ( end_marker , lump -> name ) ) { mark_end = 1 ; is_marked = 0 ; } else if ( is_marked ) { marked [ num_marked ] = * lump ; marked [ num_marked ++ ] . li_namespace = li_namespace ; } else { lumpinfo [ num_unmarked ] = * lump ; num_unmarked ++ ; } } memcpy ( & lumpinfo [ num_unmarked ] , marked , num_marked * sizeof ( * marked ) ) ; free ( marked ) ; numlumps = num_unmarked + num_marked ; if ( mark_end ) { lumpinfo [ numlumps ] . size = 0 ; lumpinfo [ numlumps ] . wadfile = NULL ; lumpinfo [ numlumps ] . li_namespace = ns_global ; strncpy ( lumpinfo [ numlumps ++ ] . name , end_marker , 8 ) ; } }
killough 4/17/98: add namespace tags
killough 4 / 17 / 98 : add namespace tags
// If this is the first start marker, add start marker to marked lumps // killough 3/20/98: force size to be 0 // killough 4/17/98 // start marking lumps // add end marker below // stop marking lumps // if we are marking lumps, // move lump to marked list // killough 4/17/98 // else move down THIS list // Append marked list to end of unmarked list // free marked list // new total number of lumps // add end marker // killough 3/20/98: force size to be 0 // killough 4/17/98