Ejemplo n.º 1
0
Archivo: cxxcode.c Proyecto: Sciumo/pcc
/*
 * Create a symbol out of a struct.
 * We call the symbol "__%THIS" to avoid interference.
 */
struct symtab *
cxxstrvar(struct symtab *so)
{
	struct symtab *sp;
	NODE *p;

	sp = lookup("__%THIS", 0);
	p = block(NAME, 0, 0, INCREF(so->stype), so->sdf, so->sap);
	p->n_sp = sp;
	defid(p, PARAM);
	nfree(p);
	return sp;
}
Ejemplo n.º 2
0
/**
 * @brief Free a string list.
 *
 * @param list pointer to the string list
 */
void listFree(char ***list)
{
    if (*list) {
        char **l = *list;

        while (*l) {
            free(*l);
            l++;
        }

        nfree(*list);
    }
}
Ejemplo n.º 3
0
static int ipc_varbuf_read(int fd, char **data, int *len)
{
    if (ipc_u32_read(fd, len))
	return -1;
    if (!(*data = malloc_l(*len)))
	goto Error;
    if (ipc_read(fd, *data, *len))
	goto Error;
    return 0;

Error:
    nfree(*data);
    return -1;
}
Ejemplo n.º 4
0
void flush_lines(int idx, struct chat_info *ci)
{
  int c = ci->line_count;
  struct msgq *p = ci->buffer, *o;

  while (p && c < (ci->max_line)) {
    ci->current_lines--;
    tputs(dcc[idx].sock, p->msg, p->len);
    nfree(p->msg);
    o = p->next;
    nfree(p);
    p = o;
    c++;
  }
  if (p != NULL) {
    if (dcc[idx].status & STAT_TELNET)
      tputs(dcc[idx].sock, "[More]: ", 8);
    else
      tputs(dcc[idx].sock, "[More]\n", 7);
  }
  ci->buffer = p;
  ci->line_count = 0;
}
Ejemplo n.º 5
0
/*
 * Main function
 */
main(int argc, char *argv[]) {
     char *buf;

     plinnames_init();
     plinnames_collect();
     if (argc > 1)
	  buf = table_outtable(tab);
     else
	  buf = table_print(tab);
     puts(buf);
     nfree(buf);
     table_destroy(tab);
     exit(0);
}
Ejemplo n.º 6
0
static void disconnect_server(int idx)
{
  if (server_online > 0)
    check_tcl_event("disconnect-server");
  server_online = 0;
  if (realservername)
    nfree(realservername);
  realservername = 0;
  if (dcc[idx].sock >= 0)
    killsock(dcc[idx].sock);
  dcc[idx].sock = -1;
  serv = -1;
  botuserhost[0] = 0;
}
Ejemplo n.º 7
0
/*
 * Main function
 */
main(int argc, char *argv[]) {
     char *buf;

     pmacnet_init();
     pmacnet_collect();
     if (argc > 1)
	  buf = table_outtable(pmacnet_tab);
     else
	  buf = table_print(pmacnet_tab);
     puts(buf);
     nfree(buf);
     table_destroy(pmacnet_tab);
     exit(0);
}
Ejemplo n.º 8
0
NODE *
mips_builtin_va_copy(NODE *f, NODE *a, TWORD t)
{
	if (a == NULL || a->n_op != CM || a->n_left->n_op == CM)
		goto bad;
	tfree(f);
	f = buildtree(ASSIGN, a->n_left, a->n_right);
	nfree(a);
	return f;

bad:
	uerror("bad argument to __buildtin_va_copy");
	return bcon(0);
}
Ejemplo n.º 9
0
/*
 * Hint to the compiler whether this expression will evaluate true or false.
 * Just ignored for now.
 */
static NODE *
builtin_expect(NODE *f, NODE *a, TWORD rt)
{

	tfree(f);
	if (a && a->n_op == CM) {
		tfree(a->n_right);
		f = a->n_left;
		nfree(a);
		a = f;
	}

	return a;
}
Ejemplo n.º 10
0
/*
 * Hint to the compiler whether this expression will evaluate true or false.
 * Just ignored for now.
 */
static NODE *
builtin_expect(const struct bitable *bt, NODE *a)
{
    NODE *f;

    if (a && a->n_op == CM) {
        tfree(a->n_right);
        f = a->n_left;
        nfree(a);
        a = f;
    }

    return a;
}
Ejemplo n.º 11
0
Archivo: pore.c Proyecto: EarlGray/ling
void pore_destroy(pore_t *pore)
{
	if (pore->evtchn != NO_EVENT)
		event_unbind(pore->evtchn);

	*pore->ref = pore->next;
	if (pore->next != 0)
		pore->next->ref = pore->ref;

	if (pore->destroy_private != 0)
		pore->destroy_private(pore);

	nfree(pore->home);
}
Ejemplo n.º 12
0
/* Set a severity to use the given sprintf output format.
 * Returns 1 for successful or 0 for failure 
 */
int elog_setformat(enum elog_severity severity, char *format)
{
     elog_checkinit();

     /* severity in range? */
     if (severity >= ELOG_NSEVERITIES || severity < 0)
	  return 0;

     if (elog_opendest[severity].format)
	  nfree(elog_opendest[severity].format);
     elog_opendest[severity].format = xnstrdup(format);

     return 1;
}
Ejemplo n.º 13
0
static void llist_free(struct llist_header *head)
{
	struct llist_entry *p, *n;

	p = head->root;
	while (p) {
		n = p->next;
		head->freedata(p->data);
		nfree(p);
		p = n;
	}
	head->root = NULL;
	head->size = 0;
}
Ejemplo n.º 14
0
void iiab_free_dir_locations() 
{
     nfree(iiab_dir_bin);
     nfree(iiab_dir_etc);
     nfree(iiab_dir_lib);
     nfree(iiab_dir_var);
     nfree(iiab_dir_launch);
     nfree(iiab_dir_lock);
}
Ejemplo n.º 15
0
static void freeskin(skin_t *skin)
{
    unsigned int i;

    nfree(skin->skindir);

    for (i=1; i<=skin->lastusedid; i++)
        skin->removewidget(skin, i);

    nfree(skin->widgets);

    freeimages(skin);
    for(i=0; i<skin->windowcount; i++)
    {
        nfree(skin->windows[i]->name);
        free(skin->windows[i]);
    }

    nfree(skin->windows);

    for (i=0; i<skin->fontcount; i++)
    {
        unsigned int x;

        nfree(skin->fonts[i]->name);

        for (x=0; x<skin->fonts[i]->charcount; x++)
            nfree(skin->fonts[i]->chars[x]);

        nfree(skin->fonts[i]->chars);

        nfree(skin->fonts[i]);
    }
    nfree(skin->fonts);
    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[SKIN FREE] skin freed\n");
    nfree(skin);
}
Ejemplo n.º 16
0
static void
setaarg(int str, union aarg *aa, NODE *p)
{
	if (str) {
		if (((str & (A1_STR|A2_STR|A3_STR)) && p->n_op != STRING) ||
		    ((str & (A1_NAME|A2_NAME|A3_NAME)) && p->n_op != NAME))
			uerror("bad arg to attribute");
		if (p->n_op == STRING) {
			aa->sarg = newstring(p->n_name, strlen(p->n_name));
		} else
			aa->sarg = (char *)p->n_sp;
		nfree(p);
	} else
		aa->iarg = (int)icons(eve(p));
}
Ejemplo n.º 17
0
static void dns_tcl_iporhostres(sockname_t *ip, char *hostn, int ok, void *other)
{
  devent_tclinfo_t *tclinfo = (devent_tclinfo_t *) other;
  Tcl_DString list;

  Tcl_DStringInit(&list);
  Tcl_DStringAppendElement(&list, tclinfo->proc);
  Tcl_DStringAppendElement(&list, iptostr(&ip->addr.sa));
  Tcl_DStringAppendElement(&list, hostn);
  Tcl_DStringAppendElement(&list, ok ? "1" : "0");

  if (tclinfo->paras) {
    EGG_CONST char *argv[2];
    char *output;

    argv[0] = Tcl_DStringValue(&list);
    argv[1] = tclinfo->paras;
    output = Tcl_Concat(2, argv);

    if (Tcl_Eval(interp, output) == TCL_ERROR) {
      putlog(LOG_MISC, "*", DCC_TCLERROR, tclinfo->proc, tcl_resultstring());
      Tcl_BackgroundError(interp);
    }
    Tcl_Free(output);
  } else if (Tcl_Eval(interp, Tcl_DStringValue(&list)) == TCL_ERROR) {
    putlog(LOG_MISC, "*", DCC_TCLERROR, tclinfo->proc, tcl_resultstring());
    Tcl_BackgroundError(interp);
  }

  Tcl_DStringFree(&list);

  nfree(tclinfo->proc);
  if (tclinfo->paras)
    nfree(tclinfo->paras);
  nfree(tclinfo);
}
Ejemplo n.º 18
0
void uiSetFileName(char *dir, char *name, int type)
{
    if(!name) return;
    if(!dir)
        setdup(&guiInfo.Filename, name);
    else
        setddup(&guiInfo.Filename, dir, name);

    filename = guiInfo.Filename;
#ifdef __WINE__
    // When the GUI receives the files to be played in guiPlaylistInitialize()
    // and guiPlaylistAdd(), it calls import_file_into_gui() where the call of
    // Wine's GetFullPathName() converts each file name into the Windows style
    // (C:\path\to\file), which needs to be reconverted for MPlayer, so that
    // it will find the filename in the Linux filesystem.
    filename = unix_name(filename);
#endif

    if (type != SAME_STREAMTYPE)
        guiInfo.StreamType = type;

    nfree(guiInfo.AudioFilename);
    nfree(guiInfo.SubtitleFilename);
}
Ejemplo n.º 19
0
/* put out code for if( ! p) goto l  */
void
putif(bigptr p, int l)
{
	NODE *p1;
	int k;

	if( ( k = (p = fixtype(p))->vtype) != TYLOGICAL) {
		if(k != TYERROR)
			err("non-logical expression in IF statement");
		frexpr(p);
	} else {
		p1 = putex1(p);
		if (p1->n_op == EQ && p1->n_right->n_op == ICON &&
		    p1->n_right->n_lval == 0 && logop(p1->n_left->n_op)) {
			/* created by OPOR */
			NODE *q = p1->n_left;
			q->n_op = negrel[q->n_op - EQ];
			nfree(p1->n_right);
			nfree(p1);
			p1 = q;
		}
		if (logop(p1->n_op) == 0)
			p1 = mkbinode(NE, p1, mklnode(ICON, 0, 0, INT), INT);
		if (p1->n_left->n_op == ICON) {
			/* change constants to right */
			NODE *p2 = p1->n_left;
			p1->n_left = p1->n_right;
			p1->n_right = p2;
			if (p1->n_op != EQ && p1->n_op != NE)
				p1->n_op = negrel[p1->n_op - EQ];
		}
		p1->n_op = negrel[p1->n_op - EQ];
		p1 = mkbinode(CBRANCH, p1, mklnode(ICON, l, 0, INT), INT);
		sendp2(p1);
	}
}
Ejemplo n.º 20
0
/* Remove the default msg/dcc/fil commands from the Tcl interpreter */
void rem_builtins(tcl_bind_list_t *table, cmd_t *cc)
{
  int k, i;
  char p[1024], *l;

  for (i = 0; cc[i].name; i++) {
    egg_snprintf(p, sizeof p, "*%s:%s", table->name,
                 cc[i].funcname ? cc[i].funcname : cc[i].name);
    l = nmalloc(Tcl_ScanElement(p, &k));
    Tcl_ConvertElement(p, l, k | TCL_DONT_USE_BRACES);
    Tcl_DeleteCommand(interp, p);
    unbind_bind_entry(table, cc[i].flags, cc[i].name, l);
    nfree(l);
  }
}
Ejemplo n.º 21
0
static void got_uninvite(struct chanset_t *chan, char *nick, char *from,
                         char *who, char *ch, struct userrec *u)
{
  masklist *inv = chan->channel.invite, *old = NULL;

  while (inv->mask[0] && rfc_casecmp(inv->mask, who)) {
    old = inv;
    inv = inv->next;
  }
  if (inv->mask[0]) {
    if (old)
      old->next = inv->next;
    else
      chan->channel.invite = inv->next;
    nfree(inv->mask);
    nfree(inv->who);
    nfree(inv);
  }
  check_tcl_mode(nick, from, u, chan->dname, "-I", who);
  if (!(chan = modebind_refresh(ch, from, &user, NULL, NULL)))
    return;

  if (channel_pending(chan))
    return;

  if (u_sticky_mask(chan->invites, who) || u_sticky_mask(global_invites, who))
    add_mode(chan, '+', 'I', who);
  if (!nick[0] && glob_bot(user) && !glob_master(user) && !chan_master(user) &&
      (chan->channel.mode & CHANINV))
    add_mode(chan, '+', 'I', who);
  if ((u_equals_mask(global_invites, who) ||
      u_equals_mask(chan->invites, who)) && me_op(chan) &&
      !channel_dynamicinvites(chan) && (!glob_bot(user) ||
      !(bot_flags(u) & BOT_SHARE)))
    add_mode(chan, '+', 'I', who);
}
Ejemplo n.º 22
0
int main(int argc, char **argv)
{
     TABLE tab1;
     char *buf1;

     iiab_start("", argc, argv, "", test_cf);
     tab1 = cf_getstatus(iiab_cf);
     buf1 = table_print(tab1);
     printf("%s\n", buf1);
     nfree(buf1);
     table_destroy(tab1);
     iiab_stop();

     exit(0);
}
Ejemplo n.º 23
0
NODE *
mips_builtin_va_copy(const struct bitable *bt, NODE *a)
{
	NODE *f;

	if (a == NULL || a->n_op != CM || a->n_left->n_op == CM)
		goto bad;
	f = buildtree(ASSIGN, a->n_left, a->n_right);
	nfree(a);
	return f;

bad:
	uerror("bad argument to __buildtin_va_copy");
	return bcon(0);
}
Ejemplo n.º 24
0
/* Mark an entry as lost and deconstruct it's contents. It will be securely
 * removed from the dcc list in the main loop.
 */
void lostdcc(int n)
{
  /* Make sure it's a valid dcc index. */
  if (n < 0 || n >= max_dcc)
    return;

  if (dcc[n].type && dcc[n].type->kill)
    dcc[n].type->kill(n, dcc[n].u.other);
  else if (dcc[n].u.other)
    nfree(dcc[n].u.other);
  egg_bzero(&dcc[n], sizeof(struct dcc_t));

  dcc[n].sock = -1;
  dcc[n].type = &DCC_LOST;
}
Ejemplo n.º 25
0
/* Set a route for a given severity to be an already opened ROUTE supplied 
 * by the caller.
 * If a route already exists for that severity, it will NOT be closed
 * before being overwritten, unless elog_ had opened the route from a purl
 * (with elog_setsevpurl()) and it is not in use for any other severity. 
 * If that is the case, then the route will be closed.
 * Returns 1 for success, 0 for failure
 */
int elog_setsevroute(enum elog_severity severity,	/* severity level */
		     ROUTE route			/* opened route */ )
{
     int i;

     elog_checkinit();

     /* severity in range? */
     if (severity >= ELOG_NSEVERITIES || severity < 0)
	  return 0;

     /* Do we have to bother to clear up? */
     if (elog_opendest[severity].purl != NULL) {
          /* elog_ opened this routine with setsevpurl(); 
	   * is there another severity with the same route? */
	  for (i=0; i < ELOG_NSEVERITIES; i++) {
	       if (i == severity)
		    continue;		/* don't count ourselves */
	       if (elog_opendest[severity].route == elog_opendest[i].route) {
		    nfree(elog_opendest[severity].purl);
		    goto noclose;	/* route is used elsewhere */
	       }
	  }

	  /* we have to clearup the old route as we allocated it but
	   * no other severity is using it */
	  route_close(elog_opendest[severity].route);
	  nfree(elog_opendest[severity].purl);
     }

noclose:
     elog_opendest[severity].purl = NULL;
     elog_opendest[severity].route = route;

     return 1;
}
Ejemplo n.º 26
0
static struct symtab *
addftn(char *n, TWORD t)
{
	NODE *p = block(TYPE, 0, 0, 0, 0, 0);
	struct symtab *sp;

	sp = lookup(addname(n), 0);
	p->n_type = INCREF(t) + (FTN-PTR);
	p->n_sp = sp;
	p->n_df = memset(permalloc(sizeof(union dimfun)), 0,
	    sizeof(union dimfun));
	defid(p, EXTERN);
	nfree(p);
	return sp;
}
Ejemplo n.º 27
0
Archivo: c.c Proyecto: cmin764/cmiN
int main()
{
    Node node = node_create(NULL, -1, 0);
    int size;
    fputs("Dimensiune: ", stdout);
    scanf("%d", &size);
    do {
        puts("[1] Afiseaza");
        puts("[2] Aloca");
        puts("[3] Elibereaza");
        puts("[4] Defragmenteaza");
        puts("[0] Iesi");
        fputs(">>> ", stdout);
        int ask;
        scanf("%d", &ask);
        if (!ask) {
            node_free(node, NULL);
            break;
        } else if (ask < 1 || ask > 4)
            puts("Optiune invalida");
        else if (ask == 1) {
            int* cnt = node_print(node);
            if (*cnt) {
                *cnt = 0;
                putchar('\n');
            }
        } else if (ask == 2) {
            int length;
            fputs("Lungime: ", stdout);
            scanf("%d", &length);
            int offset = nalloc(&node, length, size);
            if (offset == -1)
                puts("Nu se poate aloca");
            else
                printf("S-a alocat la adresa %d\n", offset);
        } else if (ask == 3) {
            int offset, length;
            fputs("Adresa: ", stdout);
            scanf("%d", &offset);
            fputs("Lungime: ", stdout);
            scanf("%d", &length);
            nfree(&node, offset, length);
        } else if (ask == 4)
            ndefrag(node);
        putchar('\n');
    } while (1);
    return 0;
}
Ejemplo n.º 28
0
void guiDone(void)
{
    if(mygui)
    {
        fprintf(stderr, "[GUI] Closed by main mplayer window\n");
        fflush(stderr);
        PostThreadMessage(threadId, WM_QUIT, 0, 0);
        WaitForSingleObject(hThread, INFINITE);
        CloseHandle(hThread);
        mygui->uninit(mygui);
        nfree(mygui);
    }
    /* Remove tray icon */
    Shell_NotifyIcon(NIM_DELETE, &nid);
    cfg_write();
}
Ejemplo n.º 29
0
/* get boot time from system */
time_t plinps_getboot_t() {
     time_t t;
     char *data;

     t = time(NULL);
     data = probe_readfile("/proc/uptime");
     if (data) {
          t -= strtol(strtok(data, " "), NULL, 10);
     } else {
	  elog_printf(ERROR, "unable to read uptime, setting ps boot to 0");
	  t = 0;
     }
     nfree(data);

     return t;
}
Ejemplo n.º 30
0
/* Changes the given dcc entry to another type.
 */
void changeover_dcc(int i, struct dcc_table *type, int xtra_size)
{
  /* Free old structure. */
  if (dcc[i].type && dcc[i].type->kill)
    dcc[i].type->kill(i, dcc[i].u.other);
  else if (dcc[i].u.other) {
    nfree(dcc[i].u.other);
    dcc[i].u.other = NULL;
  }

  dcc[i].type = type;
  if (xtra_size) {
    dcc[i].u.other = nmalloc(xtra_size);
    egg_bzero(dcc[i].u.other, xtra_size);
  }
}