当前位置: 首页>>代码示例>>C++>>正文


C++ DIE函数代码示例

本文整理汇总了C++中DIE函数的典型用法代码示例。如果您正苦于以下问题:C++ DIE函数的具体用法?C++ DIE怎么用?C++ DIE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DIE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: string_linked_list_init

StringLinkedList *
string_linked_list_init(void)
{
    StringLinkedList *sll = malloc(sizeof(StringLinkedList));
    if (sll == NULL) {
        DIE("ERROR: Not enough memory to allocate StringLinkedList")
    }
    sll->head = NULL;
    sll->tail = NULL;
    sll->len = 0;
    
    return sll;
}
开发者ID:zuigon,项目名称:version_sorter,代码行数:13,代码来源:strings.c

示例2: parse_version_word

static void
parse_version_word(char *word, StringLinkedList *sll)
{
    if (expr == NULL) {
        setup_version_regex();
    }
    
    int ovecsize = 0;
    if (pcre_fullinfo(expr, NULL, PCRE_INFO_CAPTURECOUNT, &ovecsize) != 0) {
        DIE("ERROR: Problem calling pcre_fullinfo")
    }
    ovecsize = (ovecsize + 1) * 3;
    
    int *ovector = calloc(ovecsize, sizeof(int));
    if (ovector == NULL) {
        DIE("ERROR: Not enough memory to allocate ovector")
    }

    int offset = 0;
    int flags = 0;
    char *part;

    while (0 < pcre_exec(expr, 0, word, strlen(word), offset, flags, ovector, ovecsize)) {
        
        part = malloc((WORD_MAX_LEN+1) * sizeof(char));
        if (part == NULL) {
            DIE("ERROR: Not enough memory to allocate word")
        }

        snprintf(part, WORD_MAX_LEN+1, "%.*s", ovector[1]-ovector[0], word+ovector[0]);

        string_linked_list_append(sll, part);
        
        offset = ovector[1];
        flags |= PCRE_NOTBOL;
    }
    
    free(ovector);
}
开发者ID:zuigon,项目名称:version_sorter,代码行数:39,代码来源:version_sorter.c

示例3: computeReserve

/*
	Compute reduced heap size by reserving area and rounding down to
	nearest page.
*/
double
computeReserve(double rate, int phases)
{
	assert(rate > 1.0);
	if (phases == 0)	/* not concurrent */
		return 0.0;
	else if (phases == 1) /* concurrent */
		return rate / (rate + 1.0);
	else if (phases == 2) /* concurrent - non-committing, committing */
		return (rate + 1.0) / (rate * rate + rate + 1.0);
	DIE("invalid phases");
	return 0.0;	/* NOTREACHED */
}
开发者ID:RobertHarper,项目名称:TILT-Compiler,代码行数:17,代码来源:gc.c

示例4: WaitChild

int WaitChild(pid_t pid, const char *name) {
  int err, status;

  do {
    err = waitpid(pid, &status, 0);
  } while (err == -1 && errno == EINTR);

  if (err == -1) {
    DIE("wait on %s (pid %d) failed\n", name, pid);
  }

  return status;
}
开发者ID:CydeWeys,项目名称:bazel,代码行数:13,代码来源:process-tools.c

示例5: add_to_common_env

void add_to_common_env(char *key, char *value)
{
#ifndef EXCLUDE_CGI
    common_cgi_env = realloc(common_cgi_env, (common_cgi_env_count + 2) * (sizeof(char *)));
    if (common_cgi_env== NULL) {
        DIE("Unable to allocate memory for common CGI environment variable.");
    }
    common_cgi_env[common_cgi_env_count] = env_gen_extra(key,value, 0);
    if (common_cgi_env[common_cgi_env_count] == NULL) {
        /* errors already reported */
        DIE("memory allocation failure in add_to_common_env");
    }
    common_cgi_env[++common_cgi_env_count] = NULL;
    /* I find it hard to believe that somebody would actually
     * make 90+ *common* CGI variables, but it's always better
     * to be safe.
     */
    if (common_cgi_env_count > CGI_ENV_MAX) {
        DIE("far too many common CGI environment variables added.");
    }
#endif // !EXCLUDE_CGI
}
开发者ID:jameshilliard,项目名称:WECB-BH-GPL,代码行数:22,代码来源:cgi.c

示例6: loadRom

static void loadRom()
{
	const char * file = S9xGetFilename(FILE_ROM);

	printf("ROM: %s\n", file);

	if (!Memory.LoadROM(file))
		DIE("Loading ROM failed");
	
	file = S9xGetFilename(FILE_SRAM);
	printf("SRAM: %s\n", file);
	Memory.LoadSRAM(file); 
}
开发者ID:dtzWill,项目名称:supernes,代码行数:13,代码来源:sdl.cpp

示例7: glfwWindowHint

Window::Window(Game* parent)
{
  width = height = 600;
  game = parent;
  glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
  glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
  glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  windowHandle = glfwCreateWindow(width, height, "Grass", NULL, NULL);
  glfwSetWindowPos(windowHandle,800,30);
  if (!windowHandle)
    DIE("Failed to create window");
  glfwMakeContextCurrent(windowHandle);
}
开发者ID:rspencer01,项目名称:grass,代码行数:13,代码来源:window.cpp

示例8: recv_c

int recv_c(int socket, byte *recvbuf, int bufsize) {
    LOG_DEBUG(TAG_CMD, "Receiving command");
    int bytes_total = 0;
    int bytes_received = 0;
    int bytes_missing = CMD_HEADER_LEN;
    uint16_t pl_len = 0;

    // Receive header
    while (bytes_missing > 0) {
        bytes_received = recv(socket, recvbuf+bytes_total, bytes_missing, 0);
        if (bytes_received == 0) {
            return 0;
        } else if (bytes_total > bufsize) {
            DIE(TAG_CMD, "Recvbuf overflow");
        }
        bytes_total += bytes_received;
        bytes_missing -= bytes_received;
    }

    // Check length of the packet and receive more data if needed
    memcpy(&pl_len, recvbuf+CMD_PL_LEN_OFFSET, sizeof(uint16_t));
    pl_len = ntohs(pl_len);
    bytes_received = 0;
    bytes_missing = pl_len;
    while (bytes_missing > 0) {
        bytes_received = recv(socket, recvbuf+bytes_total, bytes_missing, 0);
        if (bytes_received == 0) {
            LOG_WARN(TAG_CMD, "GUI disconnected");
            return 0;
        } else if (bytes_total > bufsize) {
            DIE(TAG_CMD, "Recvbuf overflow");
        }
        bytes_total += bytes_received;
        bytes_missing -= bytes_received;
    }
    
    LOG_DEBUG(TAG_CMD, "Received %d bytes", bytes_total);
    return bytes_total;
}
开发者ID:hmhagberg,项目名称:DHT,代码行数:39,代码来源:cmdpacket.c

示例9: close_files

static void close_files(void)
{
	size_t n_files = sizeof(files) / sizeof(files[0]);
	size_t i;
	int rc;

	for (i = 0; i < n_files; i++) {
		rc = close(fds[i]);
		DIE(rc < 0, "close");
	}

	free(fds);
}
开发者ID:alexandrucomanescu,项目名称:ASCPublic,代码行数:13,代码来源:kaio.c

示例10: show_time

/* based on show_diff_time from eachfile.c */
void show_time(FILE *out, char T, time_t val)
{
    char	buf[ELC_TIMEBUFSIZ];

    putc(T, out);
    putc('(', out);

    if (! strftime(buf, ELC_TIMEBUFSIZ, "%Y%m%d-%H%M%S", localtime(&val)) )
      DIE("strftime");
    fputs(buf, out);

    fputs(") ", out);
}
开发者ID:cbjohns,项目名称:integrit,代码行数:14,代码来源:show.c

示例11: flytec_pbrtr

	static void
flytec_pbrtr(flytec_t *flytec, track_t *track, void (*callback)(void *, const char *), void *data)
{
	char buf[9];
	if (snprintf(buf, sizeof buf, "PBRTR,%02d", track->index) != 8)
		DIE("sprintf", 0);
	flytec_puts_nmea(flytec, buf);
	flytec_expectc(flytec, XOFF);
	char line[1024];
	while (flytec_gets(flytec, line, sizeof line))
		callback(data, line);
	flytec_expectc(flytec, XON);
}
开发者ID:idaohang,项目名称:gpsbabel-flytec,代码行数:13,代码来源:flytec.c

示例12: flytec_puts_nmea

	static void
flytec_puts_nmea(flytec_t *flytec, char *s)
{
	int checksum = 0;
	char *p;
	for (p = s; *p; ++p)
		checksum ^= (unsigned char) *p;
	int len = strlen(s) + 7;
	char *buf = xmalloc(len);
	memset(buf, 0, len);
	if (snprintf(buf, len, "$%s*%02X\r\n", s, checksum) != len - 1)
		DIE("snprintf", 0);
	if (flytec->logfile)
		fprintf(flytec->logfile, "> %s", buf);
	int rc;
	do {
		rc = write(flytec->fd, buf, len);
	} while (rc == -1 && errno == EINTR);
	if (rc == -1)
		DIE("write", errno);
	free(buf);
}
开发者ID:idaohang,项目名称:gpsbabel-flytec,代码行数:22,代码来源:flytec.c

示例13: create_iocp_accept

static void create_iocp_accept(void)
{
	BOOL bRet;

	memset(&ac, 0, sizeof(ac));

	/* Create simple socket for acceptance */
	ac.sockfd = socket(PF_INET, SOCK_STREAM, 0);
	DIE(ac.sockfd == INVALID_SOCKET, "socket");

	/* Launch overlapped connection accept through AcceptEx. */
	bRet = AcceptEx(
			listenfd,
			ac.sockfd,
			ac.buffer,
			0,
			128,
			128,
			&ac.len,
			&ac.ov);
	DIE(bRet == FALSE && WSAGetLastError() != ERROR_IO_PENDING, "AcceptEx");
}
开发者ID:adrianacaciur,项目名称:PiTV,代码行数:22,代码来源:iocp_echo_server.c

示例14: pdo_sqlsrv_handle_stmt_error

// PDO error handler for the statement context.
bool pdo_sqlsrv_handle_stmt_error( sqlsrv_context& ctx, unsigned int sqlsrv_error_code, bool warning TSRMLS_DC,
                                   va_list* print_args )
{
    pdo_stmt_t* pdo_stmt = reinterpret_cast<pdo_stmt_t*>( ctx.driver());
    SQLSRV_ASSERT( pdo_stmt != NULL && pdo_stmt->dbh != NULL, "pdo_sqlsrv_handle_stmt_error: Null statement or dbh passed" );

    sqlsrv_error_auto_ptr error;

    if( sqlsrv_error_code != SQLSRV_ERROR_ODBC ) {
        core_sqlsrv_format_driver_error( ctx, get_error_message( sqlsrv_error_code ), error, SEV_ERROR TSRMLS_CC, print_args );
    }
    else {
        bool err = core_sqlsrv_get_odbc_error( ctx, 1, error, SEV_ERROR TSRMLS_CC );
        SQLSRV_ASSERT( err == true, "No ODBC error was found" );
    }

    SQLSRV_STATIC_ASSERT( sizeof( error->sqlstate ) <= sizeof( pdo_stmt->error_code ));
    strcpy_s( pdo_stmt->error_code, sizeof( pdo_stmt->error_code ), reinterpret_cast<const char*>( error->sqlstate ));

    switch( pdo_stmt->dbh->error_mode ) {
        case PDO_ERRMODE_EXCEPTION:
            if( !warning ) {

                pdo_sqlsrv_throw_exception( error TSRMLS_CC );
            }
            ctx.set_last_error( error );
            break;
        case PDO_ERRMODE_WARNING:
            if( !warning ) {
                unsigned int msg_len = strlen( reinterpret_cast<const char*>( error->native_message )) + SQL_SQLSTATE_BUFSIZE 
                    + MAX_DIGITS + 1;
                sqlsrv_malloc_auto_ptr<char> msg;
                msg = static_cast<char*>( sqlsrv_malloc( msg_len ));
                core_sqlsrv_format_message( msg, msg_len, WARNING_TEMPLATE, error->sqlstate, error->native_code, 
                                            error->native_message );
                php_error( E_WARNING, msg );
                sqlsrv_free( msg );
            }
            ctx.set_last_error( error );
            break;
        case PDO_ERRMODE_SILENT:
            ctx.set_last_error( error );
            break;
        default:
            DIE( "Unknown error mode. %1!d!", pdo_stmt->dbh->error_mode );
            break;
    }

    // return error ignored = true for warnings.
    return ( warning ? true : false );
}
开发者ID:Aymax,项目名称:msphpsql,代码行数:52,代码来源:pdo_util.cpp

示例15: print

void print(elem *hashtable, int size, char *file_name)
{
	int i;
	FILE *fd;

	if(file_name != NULL)
	{
		fd = fopen(file_name, "a");
		DIE(fd == NULL, "[print] Error opening file.");
	}

	for(i = 0; i < size; i++)
	{
		if(hashtable[i].next != NULL)
		{
			elem *temp = hashtable[i].next;
			
			if(file_name != NULL)
			{
				while(temp != NULL)
				{
					if(temp->next == NULL)
						fprintf(fd, "%s", temp->value);				/* Print without the last space */
					else
						fprintf(fd, "%s ", temp->value);

					temp = temp->next;
				}
			}else
			{
				while(temp != NULL)
				{
					if(temp->next == NULL)
						printf("%s", temp->value);
					else
						printf("%s ", temp->value);

					temp = temp->next;
				}
			}

			if(file_name != NULL)
				fprintf(fd, "\n");
			else
				printf("\n");
		}
	}

	if(file_name != NULL)
		fclose(fd);
}
开发者ID:smacrineanu,项目名称:hashtable-multi_platform,代码行数:51,代码来源:main.c


注:本文中的DIE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。