示例#1
0
Exception::~Exception() throw()
{
	try
	{
		delete m_subException;
		freeBuf(&m_file);
		freeBuf(&m_msg);
#if defined(BLOCXX_NON_THREAD_SAFE_EXCEPTION_HANDLING)
		m_mutex->release();
#endif
	}
	catch (...)
	{
		// don't let exceptions escape
	}
}
示例#2
0
文件: menu.c 项目: MFreeze/m2moca
/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  askUser
 *  Description:  ask user for action it returns -1 for an error, 0 for a move in the 
 *                hierarchy, 1 on other case
 * =====================================================================================
 */
int askUser(int *menu, int *submenu) {
    int choice = -1;
    char tmp_choice = 0;
    int nb_choice = 0;
    
    if (*menu >= NB_SUBMENU + NB_MENU || *menu < 0)
        return -1;

    while (hierarchy[*menu][nb_choice++]) {}

    switch (*menu) {
        case 0:
            while (choice <= 0 || choice >= nb_choice) {
                printAppropMenu(*menu);
                printf("\nYour choice : ");
                tmp_choice = getchar();
                choice = atoi(&tmp_choice);
                freeBuf();
            }
            if (choice <= NB_SUBMENU) {
                *menu = choice;
                return 0;
            }
            *submenu = choice;
            return 1;
            break;
        case 1:
        case 2:
            while (choice <= 0 || choice >= nb_choice) {
                printAppropMenu(*menu);
                printf("\nYour choice : ");
                tmp_choice = getchar();
                choice = atoi(&tmp_choice);
                freeBuf();
            }
            if (choice == nb_choice - 1) {
                *menu = 0;
                return 0;
            }
            *submenu = choice;
            return 1;
        break;
    }
    return 1;
}
示例#3
0
文件: malloc39.c 项目: dtzWill/SVF
void SerialReadBuf(){
	int n;
	for(n = 0; n < 100; n++){

		char** buf = readBuf();
		if(*buf!='\n'){
			printf("%s",*buf);
		}
		else{
			continue;
		}
		//free(buf);
		//free(*buf);
		freeBuf(buf);
	}
}
示例#4
0
int advFileCopy(int destfd, int srcfd, unsigned long size, const char *name, 
		int semid, int logfd, int sigfd, int confd){

    unsigned long size_so_far = 0;
    struct signalfd_siginfo fdsi;
    struct pollfd pollfds[2];
    int readret, writeret, shellReturn;
    struct buffer buf;
    struct buffer * fbuf = &buf;

    if (createBuf(fbuf, 3000) < 0) return -1;

		/* Setting up stuff for Polling */
		pollfds[0].fd = srcfd;    /* data incoming from peer */
		pollfds[0].events = POLLIN;
		pollfds[0].revents = 0;
		pollfds[1].fd = sigfd; /* communication with signalfd */
		pollfds[1].events = POLLIN;
		pollfds[1].revents = 0;

		while (1) {
			
			if ( poll(pollfds, 2, -1) <= 0) {
				if (errno == EINTR || errno == EAGAIN ) continue; /* Signals */
				logmsg(semid, logfd, LOGLEVEL_FATAL, "POLLING Error:%d - %s.\n", 
						errno, strerror(errno));
				return -1;
			}

			if ( pollfds[0].revents & POLLIN ) {  /* peer calls */
        switch((readret = readToBuf(srcfd, fbuf))){
        case -1:
          logmsg(semid, logfd, LOGLEVEL_FATAL,
            "FATAL (advFileCopy): read()-error from fd.\n");
          shellReturn = EXIT_FAILURE;
          break;
        case -2:
          logmsg(semid, logfd, LOGLEVEL_WARN,
            "WARNING (advFileCopy): couldn't read (EINTR or EAGAIN). This "
            "shouldn't happen if signalfd() is used.\n");
          shellReturn = EXIT_FAILURE;
          break;
        case 0: /* end of transfer */
          /* might also throw a POLLHUP */
          if (size != size_so_far){
            logmsg(semid, logfd, LOGLEVEL_WARN,
              "Error(advFileCopy) File transfer was quit from other side.\n");
            shellReturn = EXIT_FAILURE;
          } else {
            logmsg(semid, logfd, LOGLEVEL_WARN,
              "Error(advFileCopy) File transfer completed successfully.\n");
            shellReturn = EXIT_SUCCESS;
          }
          break;
        default:
          size_so_far += readret;
        }
        while (-2 == ( writeret =  writeBuf(destfd, fbuf)));
        if (writeret < 0) {
          logmsg(semid, logfd, LOGLEVEL_WARN,
            "Error(advFileCopy) Failure on write operation.\n");
          shellReturn = EXIT_FAILURE;
          break;
        }
      } else if(pollfds[1].revents & POLLIN) { /* incoming signal */
        readret = read(sigfd, &fdsi, sizeof(struct signalfd_siginfo));
        if (readret != sizeof(struct signalfd_siginfo)){
          fprintf(stderr, "signalfd returned something broken");
          shellReturn = EXIT_FAILURE;
        }
        switch(fdsi.ssi_signo){
          case SIGINT:
          case SIGQUIT:
            logmsg(semid, logfd, LOGLEVEL_VERBOSE, 
                "Child %d quit with status %d\n", fdsi.ssi_pid, 
                fdsi.ssi_status);
            shellReturn = EXIT_SUCCESS;
            break;
          case SIGUSR1:
            consolemsg(semid, confd, "%s is %.1F percent done\n", name, 
                (double)size_so_far/size);
            break;
          default:
            logmsg(semid, logfd, LOGLEVEL_WARN,
                "Encountered unknown signal on sigfd %d", fdsi.ssi_signo);
        }
      } else { /* Somethings broken with poll */
        fprintf(stderr, "Dunno what to do with this poll");
        shellReturn = EXIT_FAILURE;
      }
      if (shellReturn !=EXIT_NO) break;
	}
  freeBuf(fbuf);
  return shellReturn;
}
示例#5
0
GLRGBARender::~GLRGBARender(){
    for(int i=0;i<RGBA_IMG_NUM;i++){
        freeBuf(i);
    }
}