本文整理汇总了C++中INTERNAL_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ INTERNAL_ERROR函数的具体用法?C++ INTERNAL_ERROR怎么用?C++ INTERNAL_ERROR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了INTERNAL_ERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print_move_path
static void
print_move_path(const struct game *original_game,
const move *m,
enum move_notation_type mn)
{
char str[MOVE_STR_BUFFER_LENGTH];
bool first = true;
struct game *g = game_copy(original_game);
if (g == NULL)
INTERNAL_ERROR();
for (; *m != 0; ++m) {
if (!is_uci) {
if (game_turn(g) == white || first)
printf("%u. ", game_full_move_count(g));
if (first && game_turn(g) == black)
printf("... ");
}
first = false;
(void) print_move(game_current_position(g),
*m, str, mn, game_turn(g));
printf("%s ", str);
if (game_append(g, *m) != 0)
INTERNAL_ERROR();
}
game_destroy(g);
}
示例2: SRA_StatisticsNextPath
bool SRA_StatisticsNextPath ( const SRA_Statistics * self, ctx_t ctx, const char * path, const char** next )
{
FUNC_ENTRY ( ctx, rcSRA, rcDatabase, rcAccessing );
const DictionaryEntry * node = NULL;
assert ( self );
if ( path == NULL )
INTERNAL_ERROR ( xcParamNull, "path is NULL" );
else if ( path[0] == 0 )
{
node = ( const DictionaryEntry * ) BSTreeFirst ( & self -> dictionary );
}
else
{
node = ( const DictionaryEntry * ) BSTreeFind ( & self -> dictionary, ( const void * ) path, DictionaryEntryFind );
if ( node == NULL )
{
INTERNAL_ERROR ( xcUnexpected, "dictionary item '%s' is not found", path );
}
else
{
node = ( const DictionaryEntry * ) BSTNodeNext ( & node -> dad );
}
}
if ( node == NULL )
{
*next = NULL;
return false;
}
*next = node -> path;
return true;
}
示例3: SRA_StatisticsGetAsU64
uint64_t SRA_StatisticsGetAsU64 ( const SRA_Statistics * self, ctx_t ctx, const char * path )
{
FUNC_ENTRY ( ctx, rcSRA, rcDatabase, rcAccessing );
assert ( self );
if ( path == NULL )
INTERNAL_ERROR ( xcParamNull, "path is NULL" );
else
{
DictionaryEntry * node = ( DictionaryEntry * )
BSTreeFind ( & self -> dictionary, ( const void * ) path, DictionaryEntryFind );
if ( node == NULL )
{
INTERNAL_ERROR ( xcUnexpected, "dictionary item '%s' is not found", path );
}
else
{
switch ( node -> type )
{
case NGS_StatisticValueType_Int64:
if ( node -> value . i64 < 0 )
{
INTERNAL_ERROR ( xcUnexpected, "cannot convert dictionary item '%s' from in64_t to uint64_t", path );
}
else
{
return ( uint64_t ) node -> value . i64;
}
break;
case NGS_StatisticValueType_UInt64:
return node -> value . i64;
case NGS_StatisticValueType_Real:
if ( node -> value . real < 0 || node -> value . real > ULLONG_MAX )
{
INTERNAL_ERROR ( xcUnexpected, "cannot convert dictionary item '%s' from double to uint64_t", path );
}
else
{
return ( uint64_t ) xtrunc ( node -> value . real );
}
break;
case NGS_StatisticValueType_String:
return NGS_StringToU64 ( node -> value . str, ctx );
default :
INTERNAL_ERROR ( xcUnexpected, "unexpected type %u for dictionary item '%s'", node -> type, path );
break;
}
}
}
return 0;
}
示例4: SRA_StatisticsGetAsString
NGS_String* SRA_StatisticsGetAsString ( const SRA_Statistics * self, ctx_t ctx, const char * path )
{
FUNC_ENTRY ( ctx, rcSRA, rcDatabase, rcAccessing );
assert ( self );
if ( path == NULL )
INTERNAL_ERROR ( xcParamNull, "path is NULL" );
else
{
DictionaryEntry * node = ( DictionaryEntry * )
BSTreeFind ( & self -> dictionary, ( const void * ) path, DictionaryEntryFind );
if ( node == NULL )
{
INTERNAL_ERROR ( xcUnexpected, "dictionary item '%s' is not found", path );
}
else
{
switch ( node -> type )
{
case NGS_StatisticValueType_UInt64:
{
char buf[1024];
size_t num_writ;
string_printf ( buf, sizeof(buf), &num_writ, "%lu", node -> value . u64 );
return NGS_StringMakeCopy ( ctx, buf, num_writ );
}
break;
case NGS_StatisticValueType_Int64:
{
char buf[1024];
size_t num_writ;
string_printf ( buf, sizeof(buf), &num_writ, "%li", node -> value . i64 );
return NGS_StringMakeCopy ( ctx, buf, num_writ );
}
case NGS_StatisticValueType_Real:
{
char buf[1024];
size_t num_writ;
string_printf ( buf, sizeof(buf), &num_writ, "%f", node -> value . real );
return NGS_StringMakeCopy ( ctx, buf, num_writ );
}
case NGS_StatisticValueType_String:
return NGS_StringDuplicate ( node -> value . str, ctx );
default :
INTERNAL_ERROR ( xcUnexpected, "unexpected type %u for dictionary item '%s'", node -> type, path );
break;
}
}
}
return NULL;
}
示例5: handle_filt_cmd
/**
* Internal method to handle a command that relies
* on a filter name and a single key, responses are handled using
* handle_multi_response.
*/
static void handle_filt_cmd(bloom_conn_handler *handle, char *args, int args_len,
int(*filtmgr_func)(bloom_filtmgr *, char*)) {
// If we have no args, complain.
if (!args) {
handle_client_err(handle->conn, (char*)&FILT_NEEDED, FILT_NEEDED_LEN);
return;
}
// Scan past the filter name
char *key;
int key_len;
int after = buffer_after_terminator(args, args_len, ' ', &key, &key_len);
if (after == 0) {
handle_client_err(handle->conn, (char*)&UNEXPECTED_ARGS, UNEXPECTED_ARGS_LEN);
return;
}
// Call into the filter manager
int res = filtmgr_func(handle->mgr, args);
switch (res) {
case 0:
handle_client_resp(handle->conn, (char*)DONE_RESP, DONE_RESP_LEN);
break;
case -1:
handle_client_resp(handle->conn, (char*)FILT_NOT_EXIST, FILT_NOT_EXIST_LEN);
break;
case -2:
handle_client_resp(handle->conn, (char*)FILT_NOT_PROXIED, FILT_NOT_PROXIED_LEN);
break;
default:
INTERNAL_ERROR();
break;
}
}
示例6: NGS_StringToU64
static uint64_t NGS_StringToU64( const NGS_String * str, ctx_t ctx )
{
/* have to guarantee NUL-termination for strtou64/strtod */
char buf[4096];
if ( sizeof(buf) > NGS_StringSize ( str, ctx ) )
{
char* end;
uint64_t value;
string_copy ( buf, sizeof(buf),
NGS_StringData ( str, ctx ), NGS_StringSize ( str, ctx ) );
errno = 0;
value = strtou64 ( buf, &end, 10 );
if ( *end == 0 )
{
if ( errno == 0 )
{
return value;
}
}
else
{ /* attempt to parse as a double */
double dbl;
errno = 0;
dbl = strtod ( buf, &end );
if ( *end == 0 && errno == 0 && dbl >= 0 && dbl <= ULLONG_MAX )
{
return ( uint64_t ) xtrunc ( dbl );
}
}
}
INTERNAL_ERROR ( xcUnexpected, "cannot convert dictionary value '%.*s' from string to uint64",
NGS_StringSize ( str, ctx ), NGS_StringData ( str, ctx ) );
return 0;
}
示例7: switch
void CSPELL_constant_val_to_string
(
AST_constant_n_t *cp,
char *str
)
{
char const *str2;
switch (cp->kind) {
case AST_nil_const_k:
sprintf (str, "NULL");
break;
case AST_boolean_const_k:
if (cp->value.boolean_val)
sprintf (str, "ndr_true");
else
sprintf (str, "ndr_false");
break;
case AST_int_const_k:
sprintf (str, "%ld", cp->value.int_val);
break;
case AST_string_const_k:
STRTAB_str_to_string (cp->value.string_val, &str2);
sprintf (str, "\"%s\"", str2);
break;
case AST_char_const_k:
sprintf (str, "'%s'", mapchar(cp, FALSE));
break;
default:
INTERNAL_ERROR("Unsupported tag in CSPELL_constant_val_to_string");
break;
}
}
示例8: INTERNAL_ERROR
static MonomialIdeal *wrapperFrobbyAlexanderDual(const MonomialIdeal *I,
const M2_arrayint top)
// Assumption: top is an array of at least the number of variables of I
// whose v-th entry is at least as large as the v-th exp of any mingen of I
{
// Create a Frobby Ideal containing I.
int nv = I->topvar() + 1;
if (nv == 0)
{
INTERNAL_ERROR("attempting to use frobby with zero variables");
return 0;
}
mpz_t *topvec = 0;
if (top->len > 0)
{
topvec = newarray(mpz_t, top->len);
for (int i = 0; i < top->len; i++)
mpz_init_set_si(topvec[i], top->array[i]);
}
MonomialIdeal *result = FrobbyAlexanderDual(I, topvec);
// Clean up
if (topvec != 0)
{
for (int i = 0; i < top->len; i++) mpz_clear(topvec[i]);
deletearray(topvec);
}
return result;
}
示例9: ArgsGetOptU64
static
uint64_t ArgsGetOptU64 ( Args *self, const ctx_t *ctx, const char *optname, uint32_t *count )
{
rc_t rc;
uint64_t val = 0;
uint32_t dummy;
if ( count == NULL )
count = & dummy;
rc = ArgsOptionCount ( self, optname, count );
if ( rc == 0 && * count != 0 )
{
const char *str;
rc = ArgsOptionValue ( self, optname, 0, & str );
if ( rc != 0 )
INTERNAL_ERROR ( rc, "failed to retrieve '%s' parameter", optname );
else
{
char *end;
val = strtou64 ( str, & end, 0 );
if ( end [ 0 ] != 0 )
{
rc = RC ( rcExe, rcArgv, rcParsing, rcParam, rcIncorrect );
ERROR ( rc, "bad '%s' parameter: '%s'", optname, str );
}
}
}
return val;
}
示例10: _notmuch_string_list_sort
void
_notmuch_string_list_sort (notmuch_string_list_t *list)
{
notmuch_string_node_t **nodes, *node;
int i;
if (list->length == 0)
return;
nodes = talloc_array (list, notmuch_string_node_t *, list->length);
if (unlikely (nodes == NULL))
INTERNAL_ERROR ("Could not allocate memory for list sort");
for (i = 0, node = list->head; node; i++, node = node->next)
nodes[i] = node;
qsort (nodes, list->length, sizeof (*nodes), cmpnode);
for (i = 0; i < list->length - 1; ++i)
nodes[i]->next = nodes[i+1];
nodes[i]->next = NULL;
list->head = nodes[0];
list->tail = &nodes[i]->next;
talloc_free (nodes);
}
示例11: print_popular
/* Print the most common variant of a list of unique mailboxes, and
* conflate the counts. */
static void
print_popular (const search_context_t *ctx, GList *list)
{
GList *l;
mailbox_t *mailbox = NULL, *m;
int max = 0;
int total = 0;
for (l = list; l; l = l->next) {
m = l->data;
total += m->count;
if (m->count > max) {
mailbox = m;
max = m->count;
}
}
if (! mailbox)
INTERNAL_ERROR("Empty list in address hash table\n");
/* The original count is no longer needed, so overwrite. */
mailbox->count = total;
print_mailbox (ctx, mailbox);
}
示例12: set_state
/*
* set_state() -- initialize the RNG so that
* appropriate data sets can be generated.
* For each table that is to be generated, calculate the number of rows/child, and send that to the
* seed generation routine in speed_seed.c. Note: assumes that tables are completely independent.
* Returns the number of rows to be generated by the named step.
*/
DSS_HUGE
set_state(int table, long sf, long procs, long step, DSS_HUGE *extra_rows)
{
int i;
DSS_HUGE rowcount, remainder, result;
if (sf == 0 || step == 0)
return(0);
rowcount = tdefs[table].base / procs;
if ((sf / procs) > (int)MAX_32B_SCALE)
INTERNAL_ERROR("SCALE OVERFLOW. RE-RUN WITH MORE CHILDREN.");
rowcount *= sf;
remainder = (tdefs[table].base % procs) * sf;
rowcount += remainder / procs;
result = rowcount;
for (i=0; i < step - 1; i++)
{
if (table == LINE) /* special case for shared seeds */
tdefs[table].gen_seed(1, rowcount);
else
tdefs[table].gen_seed(0, rowcount);
/* need to set seeds of child in case there's a dependency */
/* NOTE: this assumes that the parent and child have the same base row count */
if (tdefs[table].child != NONE)
tdefs[tdefs[table].child].gen_seed(0,rowcount);
}
*extra_rows = remainder % procs;
if (step > procs) /* moving to the end to generate updates */
tdefs[table].gen_seed(0, *extra_rows);
return(result);
}
示例13: switch
static void CSPELL_type_tail
(
FILE *fid,
type_tail_t *tail,
boolean encoding_services /* TRUE => [encode] or [decode] on operation */
)
{
int i;
for (i = 0; i < tail->len; i++)
switch (tail->vec[i].kind) {
case p_k:
fprintf (fid, ")");
break;
case a_k:
CSPELL_array_bounds (
fid,
tail->vec[i].content.array_info.array,
tail->vec[i].content.array_info.in_typedef_or_struct);
break;
case f_k:
CSPELL_function_sig (
fid,
tail->vec[i].content.function_info.param_list,
tail->vec[i].content.function_info.function_def,
encoding_services);
break;
default:
INTERNAL_ERROR("Invalid tail kind");
}
}
示例14: INTERNAL_ERROR
void NAMETABLE_clear_temp_name_mode
(
void
)
{
NAMETABLE_temp_name_t * This,
* next;
/*
* Bugcheck if not in temporary mode.
*/
if (!NAMETABLE_names_are_temporary)
INTERNAL_ERROR ("Not in temp name mode");
/*
* Walk the list of temp name blocks, freeing the name and then the block.
*/
for (This = NAMETABLE_temp_chain; This != NULL; ) {
NAMETABLE_delete_node (This->node);
next = This->next;
FREE (This);
This = next;
}
/*
* Balance the nametable after all these deletions.
*/
NAMETABLE_balance_tree();
/*
* Clear the temporary flag and the chain head.
*/
NAMETABLE_names_are_temporary = FALSE;
NAMETABLE_temp_chain = NULL;
}
示例15: MakeNode
static
DictionaryEntry * MakeNode ( SRA_Statistics * self, ctx_t ctx, const char * path )
{
FUNC_ENTRY ( ctx, rcSRA, rcDatabase, rcAccessing );
size_t path_size = string_size ( path );
DictionaryEntry * node = malloc ( sizeof ( * node ) + path_size );
if ( node == NULL )
{
SYSTEM_ERROR ( xcNoMemory, "allocating dictionary item" );
}
else
{
rc_t rc;
string_copy ( node -> path, path_size + 1, path, path_size );
/*TODO: decide whether to allow overwriting (not allowed now) */
rc = BSTreeInsertUnique ( & self -> dictionary, & node -> dad, NULL, DictionaryEntryCompare );
if ( rc == 0 )
{
return node;
}
INTERNAL_ERROR ( xcUnexpected, "inserting dictionary item '%s' rc = %R", node -> path, rc );
free ( node );
}
return NULL;
}