コード例 #1
0
void SimFieldDictionary::setFieldValue(StringTableEntry slotName, const char *value)
{
   U32 bucket = getHashValue(slotName);
   Entry **walk = &mHashTable[bucket];
   while(*walk && (*walk)->slotName != slotName)
      walk = &((*walk)->next);

   Entry *field = *walk;
   if( !value || !*value )
   {
      if(field)
      {
         mVersion++;

         if( field->value )
            dFree(field->value);

         *walk = field->next;
         freeEntry(field);
      }
   }
   else
   {
      if(field)
      {
         if( field->value )
            dFree(field->value);

         field->value = dStrdup(value);
      }
      else
         addEntry( bucket, slotName, 0, dStrdup( value ) );
   }
}
コード例 #2
0
ファイル: decode.c プロジェクト: fredollinger/dillo
static void Decode_gzip_free(Decode *dc)
{
   (void)inflateEnd((z_stream *)dc->state);

   dFree(dc->state);
   dFree(dc->buffer);
}
コード例 #3
0
ファイル: sdpalloc.c プロジェクト: BrechtBa/casadi
void CfcFree(chfac **sf)
{
  chfac *r=*sf;
  
  if (*sf) {
    iFree(&r->shead);
    iFree(&r->ssize);
    iFree(&r->ssub);
    dFree(&r->diag);
    dFree(&r->sqrtdiag);
    iFree(&r->uhead);
    iFree(&r->ujsze);
    dFree(&r->uval);
    iFree(&r->perm);
    iFree(&r->subg);
    iFree(&r->dhead);
    iFree(&r->dbeg);
    iFree(&r->dsub);
    iFree(&r->iw);
    dFree(&r->rw);
    if (r->alldense){
      r->invp=0;
      r->ujbeg=0;
      r->usub=0;
    }else{
      iFree(&r->invp);
      iFree(&r->ujbeg);
      iFree(&r->usub);
    }
    free(r);
  }
  *sf=NULL;
} /* CfcFree */
コード例 #4
0
ファイル: http.c プロジェクト: fredollinger/dillo
/*
 * Callback function for the DNS resolver.
 * Continue connecting the socket, or abort upon error condition.
 * S->web is checked to assert the operation wasn't aborted while waiting.
 */
static void Http_dns_cb(int Status, Dlist *addr_list, void *data)
{
   int SKey = VOIDP2INT(data);
   SocketData_t *S;
   HostConnection_t *hc;

   S = a_Klist_get_data(ValidSocks, SKey);
   if (S) {
      if (!a_Web_valid(S->web)) {
         a_Chain_bfcb(OpAbort, S->Info, NULL, "Both");
         dFree(S->Info);
         Http_socket_free(SKey);

      } else if (Status == 0 && addr_list) {
         /* Successful DNS answer; save the IP */
         S->addr_list = addr_list;
         S->flags |= HTTP_SOCKET_QUEUED;
         if (S->flags & HTTP_SOCKET_USE_PROXY)
            hc = Http_host_connection_get(URL_HOST(HTTP_Proxy));
         else
            hc = Http_host_connection_get(URL_HOST(S->web->url));
         Http_socket_enqueue(&hc->queue, S);
         Http_connect_queued_sockets(hc);
      } else {
         /* DNS wasn't able to resolve the hostname */
         MSG_BW(S->web, 0, "ERROR: Dns can't resolve %s",
            (S->flags & HTTP_SOCKET_USE_PROXY) ? URL_HOST_(HTTP_Proxy) :
                                                 URL_HOST_(S->web->url));
         a_Chain_bfcb(OpAbort, S->Info, NULL, "Both");
         dFree(S->Info);
         Http_socket_free(SKey);
      }
   }
}
コード例 #5
0
ファイル: http.c プロジェクト: fredollinger/dillo
static void Http_host_connection_remove(HostConnection_t *hc)
{
    assert(hc->queue.head == NULL);
    dList_remove_fast(host_connections, hc);
    dFree(hc->host);
    dFree(hc);
}
コード例 #6
0
ファイル: cookies.c プロジェクト: fredollinger/dillo
/*
 * Delete node. This will not free any cookies that might be in node->cookies.
 */
static void Cookies_delete_node(DomainNode *node)
{
   dList_remove(domains, node);
   dFree(node->domain);
   dList_free(node->cookies);
   dFree(node);
}
コード例 #7
0
ファイル: bitvec.c プロジェクト: ESOS-Lab/HEAPO
/*
 * Free a bitvec
 */
void a_Bitvec_free(bitvec_t *bvec)
{
   if (bvec) {
      dFree(bvec->vec);
      dFree(bvec);
   }
}
コード例 #8
0
ファイル: cookies.c プロジェクト: epitron/dillo
/*
 * Read dpid's communication keys from its saved file.
 * Return value: 1 on success, -1 on error.
 */
static int Dpi_read_comm_keys(int *port)
{
   FILE *In;
   char *fname, *rcline = NULL, *tail;
   int i, ret = -1;

   fname = dStrconcat(dGethomedir(), "/.dillo/dpid_comm_keys", NULL);
   if ((In = fopen(fname, "r")) == NULL) {
      MSG_ERR("[Dpi_read_comm_keys] %s\n", dStrerror(errno));
   } else if ((rcline = dGetline(In)) == NULL) {
      MSG_ERR("[Dpi_read_comm_keys] empty file: %s\n", fname);
   } else {
      *port = strtol(rcline, &tail, 10);
      for (i = 0; *tail && isxdigit(tail[i+1]); ++i)
         SharedKey[i] = tail[i+1];
      SharedKey[i] = 0;
      ret = 1;
   }
   if (In)
      fclose(In);
   dFree(rcline);
   dFree(fname);

   return ret;
}
コード例 #9
0
ファイル: http.c プロジェクト: fredollinger/dillo
static void Http_connect_queued_sockets(HostConnection_t *hc)
{
   SocketData_t *sd;
   while (hc->active_connections < prefs.http_max_conns &&
          (sd = Http_socket_dequeue(&hc->queue))) {

      sd->flags &= ~HTTP_SOCKET_QUEUED;

      if (sd->flags & HTTP_SOCKET_TO_BE_FREED) {
          dFree(sd);
      } else if (a_Web_valid(sd->web)) {
         /* start connecting the socket */
         if (Http_connect_socket(sd->Info) < 0) {
            ChainLink *Info = sd->Info;
            MSG_BW(sd->web, 1, "ERROR: %s", dStrerror(sd->Err));
            a_Chain_bfcb(OpAbort, Info, NULL, "Both");
            Http_socket_free(VOIDP2INT(Info->LocalKey)); /* free sd */
            dFree(Info);
         } else {
            sd->connected_to = hc->host;
            hc->active_connections++;
         }
      }
   }
}
コード例 #10
0
ファイル: dpid.c プロジェクト: epitron/dillo
/*!
 * Send socket port that matches dpi_id to client
 */
void send_sockport(int sock_fd, char *dpi_tag, struct dp *dpi_attr_list)
{
   int i;
   char *dpi_id, *d_cmd, port_str[16];
   struct service *serv;

   dReturn_if_fail((dpi_id = get_message(sock_fd, dpi_tag)) != NULL);

   serv = dList_find_custom(services_list,dpi_id,(dCompareFunc)service_match);

   if (serv == NULL || (i = serv->dp_index) == -1)
      for (i = 0; i < numdpis; i++)
         if (!strncmp(dpi_attr_list[i].id, dpi_id,
                      dpi_attr_list[i].id - strchr(dpi_attr_list[i].id, '.')))
            break;

   if (i < numdpis) {
      /* found */
      snprintf(port_str, 8, "%d", dpi_attr_list[i].port);
      d_cmd = a_Dpip_build_cmd("cmd=%s msg=%s", "send_data", port_str);
      (void) CKD_WRITE(sock_fd, d_cmd);
      dFree(d_cmd);
   }

   dFree(dpi_id);
}
コード例 #11
0
ファイル: cookies.c プロジェクト: fredollinger/dillo
static void Cookies_free_cookie(CookieData_t *cookie)
{
   dFree(cookie->name);
   dFree(cookie->value);
   dFree(cookie->domain);
   dFree(cookie->path);
   dFree(cookie);
}
コード例 #12
0
ファイル: http.c プロジェクト: fredollinger/dillo
/*
 * Deallocate memory used by http module
 * (Call this one at exit time)
 */
void a_Http_freeall(void)
{
   Http_host_connection_remove_all();
   a_Klist_free(&ValidSocks);
   a_Url_free(HTTP_Proxy);
   dFree(HTTP_Proxy_Auth_base64);
   dFree(HTTP_Language_hdr);
}
コード例 #13
0
ファイル: auth.c プロジェクト: epitron/dillo
static void Auth_parse_free(AuthParse_t *auth_parse)
{
   if (auth_parse) {
      dFree((void *)auth_parse->realm);
      dFree((void *)auth_parse->nonce);
      dFree((void *)auth_parse->opaque);
      dFree((void *)auth_parse->domain);
      dFree(auth_parse);
   }
}
コード例 #14
0
ファイル: testing.cpp プロジェクト: NeoAnomaly/xray
void dMatrixComparison::reset()
{
  for (int i=0; i<mat.size(); i++) {
    dFree (mat[i]->data,mat[i]->size);
    dFree (mat[i],sizeof(dMatInfo));
  }
  mat.setSize (0);
  afterfirst = 0;
  index = 0;
}
コード例 #15
0
ASMShaderParameter* ASMShader::getNamedParameter(StringTableEntry name)
{
   for(U32 i = 0; i < mParameters.size(); i++)
   {
      if(dStricmp(mParameters[i]->mName, name) == 0)
      {
         return mParameters[i];
      }
   }
   
   //No parameter...
   const char* paramString;
   ASMShaderParameter* param = NULL;
   paramString = dStrstr(mVertexSourceString, name);
   if(paramString)
   {
      param = new ASMShaderParameter;
      const char* openBracket = dStrstr(paramString, "[");
      const char* closeBracket = dStrstr(paramString, "]");
      char* num = (char *)dMalloc((closeBracket - openBracket + 1) * sizeof(U8));
      num = dStrncpy(num, openBracket + 1, (closeBracket - (openBracket + 1)));
      num[(closeBracket - (openBracket + 1))] = NULL;
      param->mName = StringTable->insert(name);
      param->mVertexId = dAtoi(num);
      const char* env = dStrstr(paramString, "program.env");
      param->mVertexIsEnv = (env != NULL && env < openBracket);
      param->mFragmentId = -1;
      param->mFragmentIsEnv = false;
      mParameters.push_back(param);
      dFree(num);
   }
   paramString = dStrstr(mPixelSourceString, name);
   if(paramString)
   {
      if(!param)
      {
         param = new ASMShaderParameter;
         mParameters.push_back(param);
         param->mVertexId = -1;
         param->mVertexIsEnv = false;
         param->mName = StringTable->insert(name);
      }
      const char* openBracket = dStrstr(paramString, "[");
      const char* closeBracket = dStrstr(paramString, "]");
      char* num = (char *)dMalloc((closeBracket - openBracket + 1) * sizeof(U8));
      num = dStrncpy(num, openBracket + 1, (closeBracket - (openBracket + 1)));
      num[(closeBracket - (openBracket + 1))] = NULL;
      param->mFragmentId = dAtoi(num);
      const char* env = dStrstr(paramString, "program.env");
      param->mFragmentIsEnv = (env != NULL && env < openBracket);
      dFree(num);
   }
   return param;
}
コード例 #16
0
ファイル: dpid.c プロジェクト: epitron/dillo
/*! Free memory used to describe
 * a set of dpi attributes
 */
void free_dpi_attr(struct dp *dpi_attr)
{
   if (dpi_attr->id != NULL) {
      dFree(dpi_attr->id);
      dpi_attr->id = NULL;
   }
   if (dpi_attr->path != NULL) {
      dFree(dpi_attr->path);
      dpi_attr->path = NULL;
   }
}
コード例 #17
0
void ATITShader::kill()
{
   glDeleteProgramsARB(1, &mVertexProgram);
   glDeleteProgramsARB(1, &mFragmentProgram);
   for(U32 i = 0; i < mParameters.size(); i++)
   {
      delete mParameters[i];
   }
   mParameters.clear();
   dFree(mPixelSourceString);
   dFree(mVertexSourceString);
}
コード例 #18
0
HTTPObject::~HTTPObject()
{
   dFree(mHostName);
   dFree(mPath);
   dFree(mQuery);
   dFree(mPost);

   mHostName = 0;
   mPath = 0;
   mQuery = 0;
   mPost = 0;
   dFree(mBufferSave);
}
コード例 #19
0
ファイル: cookies.c プロジェクト: epitron/dillo
static void expires_server_ahead()
{
   char *string;
   time_t t = time(NULL)+1000;
   char *server_date = dStrdup(ctime(&t));
   time_t expt = t + 1000;
   char *exp_date = dStrdup(ctime(&expt));

   string = dStrconcat("name=val; expires=", exp_date, NULL);
   a_Cookies_set(string, "e2000s1000.com", "/", NULL);
   expect(__LINE__, "Cookie: name=val\r\n", "http", "e2000s1000.com", "/");

   a_Cookies_set(string, "e2000s1000s.com", "/", server_date);
   expect(__LINE__, "Cookie: name=val\r\n", "http", "e2000s1000s.com", "/");

   expt = t - 500; /* past for the server, future for us */
   dFree(exp_date);
   exp_date = dStrdup(ctime(&expt));

   string = dStrconcat("name=val; expires=", exp_date, NULL);
   a_Cookies_set(string, "e500s1000.com", "/", NULL);
   expect(__LINE__, "Cookie: name=val\r\n", "http", "e500s1000.com", "/");

   a_Cookies_set(string, "e500s1000s.com", "/", server_date);
   expect(__LINE__, "", "http", "e500s1000s.com", "/");

   expt = t; /* expire at future-for-us server date */
   dFree(exp_date);
   exp_date = dStrdup(ctime(&expt));

   string = dStrconcat("name=val; expires=", exp_date, NULL);
   a_Cookies_set(string, "e1000s1000.com", "/", NULL);
   expect(__LINE__, "Cookie: name=val\r\n", "http", "e1000s1000.com", "/");

   a_Cookies_set(string, "e1000s1000s.com", "/", server_date);
   expect(__LINE__, "", "http", "e1000s1000s.com", "/");

   expt = time(NULL); /* now */
   dFree(exp_date);
   exp_date = dStrdup(ctime(&expt));

   string = dStrconcat("name=val; expires=", exp_date, NULL);
   a_Cookies_set(string, "e0s1000.com", "/", NULL);
   expect(__LINE__, "", "http", "e0s1000.com", "/");

   a_Cookies_set(string, "e0s1000s.com", "/", server_date);
   expect(__LINE__, "", "http", "e0s1000s.com", "/");

   dFree(exp_date);
   dFree(server_date);
}
コード例 #20
0
ファイル: cache.c プロジェクト: fredollinger/dillo
/*
 * Change Content-Type for cache entry found by url.
 * from = { "http" | "meta" }
 * Return new content type.
 */
const char *a_Cache_set_content_type(const DilloUrl *url, const char *ctype,
                                     const char *from)
{
   const char *curr;
   char *major, *minor, *charset;
   CacheEntry_t *entry = Cache_entry_search(url);

   dReturn_val_if_fail (entry != NULL, NULL);

   _MSG("a_Cache_set_content_type {%s} {%s}\n", ctype, URL_STR(url));

   curr = Cache_current_content_type(entry);
   if  (entry->TypeMeta || (*from == 'h' && entry->TypeHdr) ) {
      /* Type is already been set. Do nothing.
       * BTW, META overrides TypeHdr */
   } else {
      if (*from == 'h') {
         /* Content-Type from HTTP header */
         entry->TypeHdr = dStrdup(ctype);
      } else {
         /* Content-Type from META */
         entry->TypeMeta = dStrdup(ctype);
      }
      if (a_Misc_content_type_cmp(curr, ctype)) {
         /* ctype gives one different from current */
         a_Misc_parse_content_type(ctype, &major, &minor, &charset);
         if (*from == 'm' && charset &&
             ((!major || !*major) && (!minor || !*minor))) {
            /* META only gives charset; use detected MIME type too */
            entry->TypeNorm = dStrconcat(entry->TypeDet, ctype, NULL);
         } else if (*from == 'm' &&
                    !dStrnAsciiCasecmp(ctype, "text/xhtml", 10)) {
            /* WORKAROUND: doxygen uses "text/xhtml" in META */
            entry->TypeNorm = dStrdup(entry->TypeDet);
         }
         if (charset) {
            if (entry->CharsetDecoder)
               a_Decode_free(entry->CharsetDecoder);
            entry->CharsetDecoder = a_Decode_charset_init(charset);
            curr = Cache_current_content_type(entry);

            /* Invalidate UTF8Data */
            dStr_free(entry->UTF8Data, 1);
            entry->UTF8Data = NULL;
         }
         dFree(major); dFree(minor); dFree(charset);
      }
   }
   return curr;
}
コード例 #21
0
ファイル: capi.c プロジェクト: ESOS-Lab/HEAPO
/*
 * Send a dpi cmd.
 * (For instance: add_bookmark, open_url, send_preferences, ...)
 */
int a_Capi_dpi_send_cmd(DilloUrl *url, void *bw, char *cmd, char *server,
                        int flags)
{
   capi_conn_t *conn;
   DataBuf *dbuf;

   if (flags & 1) {
      /* open a new connection to server */

      /* Create a new connection data struct and add it to the list */
      conn = Capi_conn_new(url, bw, server, cmd);
      /* start the CCC operations */
      a_Capi_ccc(OpStart, 2, BCK, a_Chain_new(), conn, server);
      a_Capi_ccc(OpStart, 1, BCK, a_Chain_new(), conn, server);

   } else {
      /* Re-use an open connection */
      conn = Capi_conn_find(server);
      if (conn) {
         /* found */
         dbuf = a_Chain_dbuf_new(cmd, (int)strlen(cmd), 0);
         a_Capi_ccc(OpSend, 1, BCK, conn->InfoSend, dbuf, NULL);
         dFree(dbuf);
      } else {
         MSG(" ERROR: [a_Capi_dpi_send_cmd] No open connection found\n");
      }
   }

   return 0;
}
コード例 #22
0
ファイル: dpid.c プロジェクト: epitron/dillo
/*! Remove dpid_comm_keys file.
 * This avoids that dillo instances connect to a stale port after dpid
 * has exited (e.g. after a reboot).
 */
void cleanup()
{
   char *fname;
   fname = dStrconcat(dGethomedir(), "/", dotDILLO_DPID_COMM_KEYS, NULL);
   unlink(fname);
   dFree(fname);
}
コード例 #23
0
ファイル: capi.c プロジェクト: ESOS-Lab/HEAPO
/*
 * Build the dpip command tag, according to URL and server.
 */
static char *Capi_dpi_build_cmd(DilloWeb *web, char *server)
{
   char *cmd;

   if (strcmp(server, "proto.https") == 0) {
      /* Let's be kind and make the HTTP query string for the dpi */
      char *proxy_connect = a_Http_make_connect_str(web->url);
      Dstr *http_query = a_Http_make_query_str(web->url, FALSE);
      /* BUG: embedded NULLs in query data will truncate message */
      if (proxy_connect) {
         const char *proxy_urlstr = a_Http_get_proxy_urlstr();
         cmd = a_Dpip_build_cmd("cmd=%s proxy_url=%s proxy_connect=%s "
                                "url=%s query=%s", "open_url", proxy_urlstr,
                                proxy_connect, URL_STR(web->url),
                                http_query->str);
      } else {
         cmd = a_Dpip_build_cmd("cmd=%s url=%s query=%s",
                                "open_url", URL_STR(web->url),http_query->str);
      }
      dFree(proxy_connect);
      dStr_free(http_query, 1);

   } else if (strcmp(server, "downloads") == 0) {
      /* let the downloads server get it */
      cmd = a_Dpip_build_cmd("cmd=%s url=%s destination=%s",
                             "download", URL_STR(web->url), web->filename);

   } else {
      /* For everyone else, the url string is enough... */
      cmd = a_Dpip_build_cmd("cmd=%s url=%s", "open_url", URL_STR(web->url));
   }
   return cmd;
}
コード例 #24
0
ファイル: http.c プロジェクト: fredollinger/dillo
/*
 * Asynchronously create a new http connection for 'Url'
 * We'll set some socket parameters; the rest will be set later
 * when the IP is known.
 * ( Data1 = Web structure )
 * Return value: 0 on success, -1 otherwise
 */
static int Http_get(ChainLink *Info, void *Data1)
{
   SocketData_t *S;
   char *hostname;

   S = a_Klist_get_data(ValidSocks, VOIDP2INT(Info->LocalKey));
   /* Reference Web data */
   S->web = Data1;
   /* Reference Info data */
   S->Info = Info;

   /* Proxy support */
   if (Http_must_use_proxy(S->web->url)) {
      hostname = dStrdup(URL_HOST(HTTP_Proxy));
      S->port = URL_PORT(HTTP_Proxy);
      S->flags |= HTTP_SOCKET_USE_PROXY;
   } else {
      hostname = dStrdup(URL_HOST(S->web->url));
      S->port = URL_PORT(S->web->url);
      S->flags &= ~HTTP_SOCKET_USE_PROXY;
   }

   /* Let the user know what we'll do */
   MSG_BW(S->web, 1, "DNS resolving %s", URL_HOST_(S->web->url));

   /* Let the DNS engine resolve the hostname, and when done,
    * we'll try to connect the socket from the callback function */
   a_Dns_resolve(hostname, Http_dns_cb, Info->LocalKey);

   dFree(hostname);
   return 0;
}
コード例 #25
0
void SimObjectMemento::save( SimObject *object )
{
   // Cleanup any existing state data.
   dFree( mState );
   mObjectName = String::EmptyString;

	// Use a stream to save the state.
   MemStream stream( 256 );

   U32 writeFlags = 0;
	SimDataBlock* db = dynamic_cast<SimDataBlock*>(object);
	if( !db )
		stream.write( sizeof( "return " ) - 1, "return " );
	else
   {
		mIsDatablock = true;

      // Cull the datablock name from the output so that
      // we can easily replace it in case the datablock's name
      // is already taken when we call restore().  We can't use the same
      // setup as with non-datablock classes as the return semantics
      // are not the same.

      writeFlags |= SimObject::NoName;
   }
	
   object->write( stream, 0, writeFlags );
   stream.write( (UTF8)0 );

   // Steal the data away from the stream.
   mState = (UTF8*)stream.takeBuffer();
   mObjectName = object->getName();
}
コード例 #26
0
ファイル: http.c プロジェクト: fredollinger/dillo
/*
 * Test proxy settings and check the no_proxy domains list
 * Return value: whether to use proxy or not.
 */
static int Http_must_use_proxy(const DilloUrl *url)
{
   char *np, *p, *tok;
   int ret = 0;

   if (HTTP_Proxy) {
      ret = 1;
      if (prefs.no_proxy) {
         const char *host = URL_HOST(url);
         size_t host_len = strlen(host);

         np = dStrdup(prefs.no_proxy);
         for (p = np; (tok = dStrsep(&p, " "));  ) {
            int start = host_len - strlen(tok);

            if (start >= 0 && dStrAsciiCasecmp(host + start, tok) == 0) {
               /* no_proxy token is suffix of host string */
               ret = 0;
               break;
            }
         }
         dFree(np);
      }
   }
   _MSG("Http_must_use_proxy: %s\n  %s\n", URL_STR(url), ret ? "YES":"NO");
   return ret;
}
コード例 #27
0
void dGeomSetBody (dxGeom *g, dxBody *b)
{
  dAASSERT (g);
  dUASSERT (g->gflags & GEOM_PLACEABLE,"geom must be placeable");
  CHECK_NOT_LOCKED (g->parent_space);

  if (b) {
    if (!g->body) dFree (g->pos,sizeof(dxPosR));
    g->pos = b->pos;
    g->R = b->R;
    dGeomMoved (g);
    if (g->body != b) {
      g->bodyRemove();
      g->bodyAdd (b);
    }
  }
  else {
    if (g->body) {
      dxPosR *pr = (dxPosR*) dAlloc (sizeof(dxPosR));
      g->pos = pr->pos;
      g->R = pr->R;
      memcpy (g->pos,g->body->pos,sizeof(dVector3));
      memcpy (g->R,g->body->R,sizeof(dMatrix3));
      g->bodyRemove();
    }
    // dGeomMoved() should not be called if the body is being set to 0, as the
    // new position of the geom is set to the old position of the body, so the
    // effective position of the geom remains unchanged.
  }
}
コード例 #28
0
void dArrayBase::_freeAll (int sizeofT)
{
  if (_data) {
    if (_data == this+1) return;	// if constructLocalArray() was called
    dFree (_data,_anum * sizeofT);
  }
}
コード例 #29
0
dxQuadTreeSpace::~dxQuadTreeSpace(){
	int Depth = 0;
	Block* Current = &Blocks[0];
	while (Current){
		Depth++;
		Current = Current->Children;
	}

	int BlockCount = 0;
	for (int i = 0; i < Depth; i++){
		BlockCount += (int)pow((dReal)SPLITS, i);
	}

	dFree(Blocks, BlockCount * sizeof(Block));
	dFree(CurrentChild, (Depth + 1) * sizeof(int));
}
コード例 #30
0
ファイル: capi.c プロジェクト: ESOS-Lab/HEAPO
/*
 * If the url belongs to a dpi server, return its name.
 */
static int Capi_url_uses_dpi(DilloUrl *url, char **server_ptr)
{
   char *p, *server = NULL, *url_str = URL_STR(url);
   Dstr *tmp;

   if ((dStrncasecmp(url_str, "http:", 5) == 0) ||
       (dStrncasecmp(url_str, "about:", 6) == 0)) {
      /* URL doesn't use dpi (server = NULL) */
   } else if (dStrncasecmp(url_str, "dpi:/", 5) == 0) {
      /* dpi prefix, get this server's name */
      if ((p = strchr(url_str + 5, '/')) != NULL) {
         server = dStrndup(url_str + 5, (uint_t)(p - url_str - 5));
      } else {
         server = dStrdup("?");
      }
      if (strcmp(server, "bm") == 0) {
         dFree(server);
         server = dStrdup("bookmarks");
      }
   } else if ((p = strchr(url_str, ':')) != NULL) {
      tmp = dStr_new("proto.");
      dStr_append_l(tmp, url_str, p - url_str);
      server = tmp->str;
      dStr_free(tmp, 0);
   }

   return ((*server_ptr = server) ? 1 : 0);
}