pike.git / src / call_out.c

version» Context lines:

pike.git/src/call_out.c:6:   #include <stdio.h>   #include "global.h"   #include "array.h"   #include "call_out.h"   #include "dynamic_buffer.h"   #include "object.h"   #include "interpret.h"   #include "error.h"   #include "builtin_efuns.h"   #include "memory.h" + #include "main.h"      call_out **pending_calls=0; /* pointer to first busy pointer */   int num_pending_calls; /* no of busy pointers in buffer */   static call_out **call_buffer=0; /* pointer to buffer */   static int call_buffer_size; /* no of pointers in buffer */      extern time_t current_time;      static void verify_call_outs()   {   #ifdef DEBUG    struct array *v;    int e; -  if(call_buffer) return; +     -  +  if(!d_flag) return; +  if(!call_buffer) return; +     if(num_pending_calls<0 || num_pending_calls>call_buffer_size)    fatal("Error in call out tables.\n");       if(pending_calls+num_pending_calls!=call_buffer+call_buffer_size)    fatal("Error in call out tables.\n");       for(e=0;e<num_pending_calls;e++)    {    if(e)    { -  if(pending_calls[e-1]>pending_calls[e]) +  if(pending_calls[e-1]->time>pending_calls[e]->time)    fatal("Error in call out order.\n");    }       if(!(v=pending_calls[e]->args))    fatal("No arguments to call\n");       if(v->refs!=1)    fatal("Array should exactly have one reference.\n");       if(v->malloced_size<v->size)
pike.git/src/call_out.c:104:    new->caller->refs++;    }else{    new->caller=0;    }       new->args=sp[-1].u.array;    sp -= 2;       /* time to link it into the buffer using binsearch */    pos=pending_calls; -  if(new->time>current_time+1) /* do we need to search where ?*/ -  { +     e=num_pending_calls;    while(e>0)    {    c=e/2;    if(new->time>pos[c]->time)    {    pos+=c+1;    e-=c+1;    }else{    e=c;    }    } -  } +     pos--;    pending_calls--;    for(p=pending_calls;p<pos;p++) p[0]=p[1];    *pos=new;    num_pending_calls++;    -  +  verify_call_outs();    return 1;   }      void f_call_out(INT32 args)   {    struct svalue tmp;    if(args<2)    error("Too few arguments to call_out.\n");       /* Swap, for compatibility */