Search Results

Search found 6123 results on 245 pages for 'unsigned char'.

Page 85/245 | < Previous Page | 81 82 83 84 85 86 87 88 89 90 91 92  | Next Page >

  • C#: check if a string start with any character in a list

    - by JoesyXHN
    Hi, I want to check whether a string starts with any character in a list. My current implementation in C# is as follows: char[] columnChars = new char[] { 'A', 'B', 'C', 'D', 'E' }; private bool startWithColumn(string toCheck) { for(int i=0; i<columnChars.Length; i++) if (toCheck.StartsWith(columnChars[i]+"")) { return true; } return false; } I would like to know if any solution is better?

    Read the article

  • implicit declaration of

    - by gcc
    int i=0; char **mainp; for(i=0;i<2;++i) { mainp[i]=malloc(sizeof(char)*200); if(!scanf("%[^#],#",mainp[i])) break; if(i<2) scanf("%[^#],#",mainp[i]); } why does gcc send me that warnings warning: implicit declaration of function ‘scanf’ warning: incompatible implicit declaration of built-in function ‘scanf’ warning: ‘mainp’ may be used uninitialized in this function

    Read the article

  • "Implicit declaration" warning

    - by gcc
    For this code: int i=0; char **mainp; for(i=0;i<2;++i) { mainp[i]=malloc(sizeof(char)*200); if(!scanf("%[^#],#",mainp[i])) break; if(i<2) scanf("%[^#],#",mainp[i]); } GCC emits the warnings: warning: implicit declaration of function ‘scanf’ warning: incompatible implicit declaration of built-in function ‘scanf’ warning: ‘mainp’ may be used uninitialized in this function And I get a segmentation fault at runtime

    Read the article

  • how does sizeof work with array in C++

    - by skydoor
    Hi, I was told the array name is a pointer char a[] = "a" but when sizeof(a) = 2 why not it is a size of pointer here? however when I define it like this char* a ="a"; we get sizeof(a) =4; Well, I think I need more information about how does sizeof work with the array names.... Can anyone elaborate that?

    Read the article

  • Float to binary in C++

    - by Eric
    Hi, I'm wondering if there is a way to represent a float using a char in C++? For example: int main() { float test = 4.7567; char result = charRepresentation(test); return 0; } I read that probably using bitset I can do it but I'm not pretty sure.

    Read the article

  • curl problems in c++ class

    - by Danilo
    I read a few articles on c++ / curl here on stackoverflow and assembled the following. The main goal is to handle the whole request in an instance of a class -- and maybe later in a secondary thread. My problem is: "content_" seems to stay empty though its the same addr and HttpFetch.h: class HttpFetch { private: CURL *curl; static size_t handle(char * data, size_t size, size_t nmemb, void * p); size_t handle_impl(char * data, size_t size, size_t nmemb); public: std::string content_; static std::string url_; HttpFetch(std::string url); void start(); std::string data(); }; HttpFetch.cpp: HttpFetch::HttpFetch(std::string url) { curl_global_init(CURL_GLOBAL_ALL); //pretty obvious curl = curl_easy_init(); content_.append("Test"); std::cout << &content_ << "\n"; curl_easy_setopt(curl, CURLOPT_URL, &url); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &content_); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &HttpFetch::handle); //curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); //tell curl to output its progress curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); //std::cout << &content_ << "\n"; } void HttpFetch::start() { curl_easy_perform(curl); curl_easy_cleanup(curl); } size_t HttpFetch::handle(char * data, size_t size, size_t nmemb, void * p) { std::string *stuff = reinterpret_cast<std::string*>(p); stuff->append(data, size * nmemb); std::cout << stuff << "\n"; // has content from data in it! return size * nmemb; } main.cpp: #include "HttpFetch.h" int main(int argc, const char * argv[]) { HttpFetch call = *new HttpFetch("http://www.example.com"); call.start(); ::std::cout << call.content_ << "\n" } Thanks in advance

    Read the article

  • Remove control M from a text file in C

    - by Werner
    Hi, ist is possible? What would be the easiest way? I tried to compare in the input string character to character so if(char([i]=="^M") char[i]="" but it does not work. By the way, if I were able to check it, what is the wistes substitution? to "" ? Thanks

    Read the article

  • This is a valid C code but not a valid C++ code?

    - by claws
    In some library I'm using (written in C) its StorePGM(image, width, height, filename) char *image; int width, height; char *filename; { // something something } All functions are defined this way. I never seen such function definitions in my life. They seem to be valid to MSVC but when I compile it as C++ it gives errors. What is it? some kind of old version C?

    Read the article

  • Searching strings C

    - by Skittles
    First time posting here so I'm sorry if I mess up. I need to search a string and return any strings containing the search data with the search data highlighted. If my string is Hi my name is and I searched name it would produce Hi my NAME is This is a quick code I wrote that works but it only works once. If I try and search again it seg faults. I was hoping someone could hint me at a better way to write this because this code is disgusting! void search(char * srcStr, int n){ int cnt = 0, pnt,i = 0; char tmpText[500]; char tmpName[500]; char *ptr, *ptr2, *ptrLast; int num; while(*(node->text+cnt) != '\0'){ //finds length of string cnt++; } for(pnt = 0; pnt < cnt; pnt++){ //copies node->text into a tmp string tmpText[pnt] = *(node->text+pnt); } tmpText[pnt+1] = '\0'; //prints up to first occurrence of srcStr ptr = strcasestr(tmpText, srcStr); for(num = 0; num < ptr-tmpText; num++){ printf("%c",tmpText[num]); } //prints first occurrence of srcStr in capitals for(num = 0; num < n; num++){ printf("%c",toupper(tmpText[ptr-tmpText+num])); } ptr2 = strcasestr((ptr+n),srcStr); for(num = (ptr-tmpText+n); num < (ptr2-tmpText); num++){ printf("%c",tmpText[num]); } while((ptr = strcasestr((ptr+n), srcStr)) != NULL){ ptr2 = strcasestr((ptr+n),srcStr); for(num = (ptr-tmpText+n); num < (ptr2-tmpText); num++){ printf("%c",tmpText[num]); } for(num = 0; num < n; num++){ printf("%c",toupper(tmpText[ptr-tmpText+num])); } ptrLast = ptr; } //prints remaining string after last occurrence for(num = (ptrLast-tmpText+n); num < cnt; num++){ printf("%c",tmpText[num]); } }

    Read the article

  • Convert __declspec to _export C++

    - by SroMah
    Hi, I am converting the following function. But the new converted function is not executed. Any ideas? Old Function extern "C" DWORD __declspec(dllexport) FAR MyFunc (char *value1, int *value2) New Function extern "C" DWORD _export FAR MyFunc (char *value1, int *value2)

    Read the article

  • Return an empty C-String

    - by Evorlor
    Simple Question: How do you return an empty C-String with as little code as possible? I have code that needs to return an empty char*. I am looking for something along the lines of return "";. I know there are several ways to do this, but I am looking for the most efficient way possible. Using return ""; gives warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings] Thanks!

    Read the article

  • MySql - Get row number on select

    - by George
    Can I run a select statement and get the row number if the items are sorted? I have a table like this: mysql> describe orders; +-------------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------------+------+-----+---------+----------------+ | orderID | bigint(20) unsigned | NO | PRI | NULL | auto_increment | | itemID | bigint(20) unsigned | NO | | NULL | | +-------------+---------------------+------+-----+---------+----------------+ I can then run this query to get the number of orders by ID: SELECT itemID, COUNT(*) as ordercount FROM orders GROUP BY itemID ORDER BY ordercount DESC; This gives me a count of each itemID in the table like this: +--------+------------+ | itemID | ordercount | +--------+------------+ | 388 | 3 | | 234 | 2 | | 3432 | 1 | | 693 | 1 | | 3459 | 1 | +--------+------------+ I want to get the row number as well, so I could tell that itemID 388 is the first row, 234 is second, etc (essentially the ranking of the orders, not just a raw count). I know I can do this in java when I get the result set back, but I was wondering if there was a way to handle it purely in SQL.

    Read the article

  • djb2 Hash Function

    - by Jainish
    I am using the djb2 algorithm to generate the hash key for a string which is as follows hash(unsigned char *str) { unsigned long hash = 5381; int c; while (c = *str++) hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ return hash; } Now with every loop there is a multiplication with two big numbers, After some time with the 4th of 5th character of the string there is a overflow as the hash value becomes huge What is the correct way to refactor so that the hash value does not overflow and the hashing also happens correctly

    Read the article

  • getting rid of filesort on WordPress MySQL query

    - by Hans
    An instance of WordPress that I manage goes down about once a day due to this monster MySQL query taking far too long: SELECT SQL_CALC_FOUND_ROWS distinct wp_posts.* FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_term_taxonomy ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id LEFT JOIN wp_ec3_schedule ec3_sch ON ec3_sch.post_id=id WHERE 1=1 AND wp_posts.ID NOT IN ( SELECT tr.object_id FROM wp_term_relationships AS tr INNER JOIN wp_term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy = 'category' AND tt.term_id IN ('1050') ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') AND NOT EXISTS (SELECT * FROM wp_term_relationships JOIN wp_term_taxonomy ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id WHERE wp_term_relationships.object_id = wp_posts.ID AND wp_term_taxonomy.taxonomy = 'category' AND wp_term_taxonomy.term_id IN (533,3567) ) AND ec3_sch.post_id IS NULL GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10; What do I have to do to get rid of the very slow filesort? I would think that the multicolumn type_status_date index would be fast enough. The EXPLAIN EXTENDED output is below. +----+--------------------+-----------------------+--------+-----------------------------------+------------------+---------+---------------------------------------------------------------------------------+------+----------------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+--------------------+-----------------------+--------+-----------------------------------+------------------+---------+---------------------------------------------------------------------------------+------+----------------------------------------------+ | 1 | PRIMARY | wp_posts | ref | type_status_date | type_status_date | 124 | const,const | 7034 | Using where; Using temporary; Using filesort | | 1 | PRIMARY | wp_term_relationships | ref | PRIMARY | PRIMARY | 8 | bwog_wordpress_w.wp_posts.ID | 373 | Using index | | 1 | PRIMARY | wp_term_taxonomy | eq_ref | PRIMARY | PRIMARY | 8 | bwog_wordpress_w.wp_term_relationships.term_taxonomy_id | 1 | Using index | | 1 | PRIMARY | ec3_sch | ref | post_id_index | post_id_index | 9 | bwog_wordpress_w.wp_posts.ID | 1 | Using where; Using index | | 3 | DEPENDENT SUBQUERY | wp_term_taxonomy | range | PRIMARY,term_id_taxonomy,taxonomy | term_id_taxonomy | 106 | NULL | 2 | Using where | | 3 | DEPENDENT SUBQUERY | wp_term_relationships | eq_ref | PRIMARY,term_taxonomy_id | PRIMARY | 16 | bwog_wordpress_w.wp_posts.ID,bwog_wordpress_w.wp_term_taxonomy.term_taxonomy_id | 1 | Using index | | 2 | DEPENDENT SUBQUERY | tt | const | PRIMARY,term_id_taxonomy,taxonomy | term_id_taxonomy | 106 | const,const | 1 | | | 2 | DEPENDENT SUBQUERY | tr | eq_ref | PRIMARY,term_taxonomy_id | PRIMARY | 16 | func,const | 1 | Using index | +----+--------------------+-----------------------+--------+-----------------------------------+------------------+---------+---------------------------------------------------------------------------------+------+----------------------------------------------+ 8 rows in set, 2 warnings (0.05 sec) And CREATE TABLE: CREATE TABLE `wp_posts` ( `ID` bigint(20) unsigned NOT NULL auto_increment, `post_author` bigint(20) unsigned NOT NULL default '0', `post_date` datetime NOT NULL default '0000-00-00 00:00:00', `post_date_gmt` datetime NOT NULL default '0000-00-00 00:00:00', `post_content` longtext NOT NULL, `post_title` text NOT NULL, `post_excerpt` text NOT NULL, `post_status` varchar(20) NOT NULL default 'publish', `comment_status` varchar(20) NOT NULL default 'open', `ping_status` varchar(20) NOT NULL default 'open', `post_password` varchar(20) NOT NULL default '', `post_name` varchar(200) NOT NULL default '', `to_ping` text NOT NULL, `pinged` text NOT NULL, `post_modified` datetime NOT NULL default '0000-00-00 00:00:00', `post_modified_gmt` datetime NOT NULL default '0000-00-00 00:00:00', `post_content_filtered` text NOT NULL, `post_parent` bigint(20) unsigned NOT NULL default '0', `guid` varchar(255) NOT NULL default '', `menu_order` int(11) NOT NULL default '0', `post_type` varchar(20) NOT NULL default 'post', `post_mime_type` varchar(100) NOT NULL default '', `comment_count` bigint(20) NOT NULL default '0', `robotsmeta` varchar(64) default NULL, PRIMARY KEY (`ID`), KEY `post_name` (`post_name`), KEY `type_status_date` (`post_type`,`post_status`,`post_date`,`ID`), KEY `post_parent` (`post_parent`), KEY `post_date` (`post_date`), FULLTEXT KEY `post_related` (`post_title`,`post_content`) )

    Read the article

  • C++ / error LNK2019 - XpokerEval library

    - by user1068115
    I have been struggling all the afternoon with the XPokerEval Library I downloaded here: http://www.codingthewheel.com/archives/poker-hand-evaluator-roundup#xpokereval I am trying to make the XPokerEval.PokerSim work, using Visual C++ 2010 express but i get the following errors: 1>psim_test.obj : error LNK2019: unresolved external symbol "void __cdecl SimulateHand(char const *,struct SimResults *,float,float,unsigned int)" (?SimulateHand@@YAXPBDPAUSimResults@@MMI@Z) referenced in function _wmain 1>psim_test.obj : error LNK2019: unresolved external symbol "unsigned int __cdecl RankHand(int const *)" (?RankHand@@YAIPBH@Z) referenced in function _wmain Do you think this can be due to a missing link to a library or a incompatibility with my IDE? The script uses the Pokersource Poker-Eval library which is also included in the zip file, I added to the project directories but it still does not work! I cannot figure out why and I am getting mad! Thanks in advance for any tips on this!

    Read the article

  • How create UIImage from bytes ?

    - by Sergey
    Hello, all! I need in UIImage created from my colors (for example, i need in image 1x1 pixel with black color). I've got array: unsigned char *color[] = {0, 0, 0, 1}; How can i create UIImage from this array ? I've try unsigned char *bytes[4] = {0,0,0,1}; NSData *data = [NSData dataWithBytes:bytes length:4]; UIImage *img = [UIImage imageWithData:data]; but this method has no result...

    Read the article

  • Why gcc4 warn and how to avoid it

    - by vitaly.v.ch
    I have a function declared as: void event_add_card (EventAddr addr, EventType type, unsigned char card); and union typedef union EventData { float money; /**< money info */ unsigned char card; /**< new card */ } EventData; When i compile following code: EventData data = {}; event_add_card (0,0, data.card); with enabled warning -Wconversion I receive following warning: player-stud.c|71| warning: passing argument 3 of 'event_add_card' with different width due to prototype Why gcc4 unsuccessful and how to fix It???

    Read the article

  • Hung JVM consuming 100% CPU

    - by Bogdan
    We have a JAVA server running on Sun JRE 6u20 on Linux 32-bit (CentOS). We use the Server Hotspot with CMS collector with the following options (I've only provided the relevant ones): -Xmx896m -Xss128k -XX:NewSize=384M -XX:MaxPermSize=96m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC Sometimes, after running for a while, the JVM seems to slip into a hung state, whereby even though we don't make any requests to the application, the CPU continues to spin at 100% (we have 8 logical CPUs, so it looks like only one CPU does the spinning). In this state the JVM doesn't respond to SIGHUP signals (kill -3) and we can't connect to it normally with jstack. We CAN connect with "jstack -F", but the output is dodgy (we can see lots of NullPointerExceptions from JStack apparently because it wasn't able to 'walk' some stacks). So the "jstack -F" output seems to be useless. We have run a stack dump from "gdb" though, and we were able to match the thread id that spins the CPU (we found that using "top" with a per-thread view - "H" option) with a thread stack that appears in the gdb result and this is how it looks like: Thread 443 (Thread 0x7e5b90 (LWP 26310)): #0 0x0115ebd3 in CompactibleFreeListSpace::block_size(HeapWord const*) const () from /usr/java/jdk1.6.0_20/jre/lib/i386/server/libjvm.so #1 0x01160ff9 in CompactibleFreeListSpace::prepare_for_compaction(CompactPoint*) () from /usr/java/jdk1.6.0_20/jre/lib/i386/server/libjvm.so #2 0x0123456c in Generation::prepare_for_compaction(CompactPoint*) () from /usr/java/jdk1.6.0_20/jre/lib/i386/server/libjvm.so #3 0x01229b2c in GenCollectedHeap::prepare_for_compaction() () from /usr/java/jdk1.6.0_20/jre/lib/i386/server/libjvm.so #4 0x0122a7fc in GenMarkSweep::invoke_at_safepoint(int, ReferenceProcessor*, bool) () from /usr/java/jdk1.6.0_20/jre/lib/i386/server/libjvm.so #5 0x01186024 in CMSCollector::do_compaction_work(bool) () from /usr/java/jdk1.6.0_20/jre/lib/i386/server/libjvm.so #6 0x011859ee in CMSCollector::acquire_control_and_collect(bool, bool) () from /usr/java/jdk1.6.0_20/jre/lib/i386/server/libjvm.so #7 0x01185705 in ConcurrentMarkSweepGeneration::collect(bool, bool, unsigned int, bool) () from /usr/java/jdk1.6.0_20/jre/lib/i386/server/libjvm.so #8 0x01227f53 in GenCollectedHeap::do_collection(bool, bool, unsigned int, bool, int) () from /usr/java/jdk1.6.0_20/jre/lib/i386/server/libjvm.so #9 0x0115c7b5 in GenCollectorPolicy::satisfy_failed_allocation(unsigned int, bool) () from /usr/java/jdk1.6.0_20/jre/lib/i386/server/libjvm.so #10 0x0122859c in GenCollectedHeap::satisfy_failed_allocation(unsigned int, bool) () from /usr/java/jdk1.6.0_20/jre/lib/i386/server/libjvm.so #11 0x0158a8ce in VM_GenCollectForAllocation::doit() () from /usr/java/jdk1.6.0_20/jre/lib/i386/server/libjvm.so #12 0x015987e6 in VM_Operation::evaluate() () from /usr/java/jdk1.6.0_20/jre/lib/i386/server/libjvm.so #13 0x01597c93 in VMThread::evaluate_operation(VM_Operation*) () from /usr/java/jdk1.6.0_20/jre/lib/i386/server/libjvm.so #14 0x01597f0f in VMThread::loop() () from /usr/java/jdk1.6.0_20/jre/lib/i386/server/libjvm.so #15 0x015979f0 in VMThread::run() () from /usr/java/jdk1.6.0_20/jre/lib/i386/server/libjvm.so #16 0x0145c24e in java_start(Thread*) () from /usr/java/jdk1.6.0_20/jre/lib/i386/server/libjvm.so #17 0x00ccd46b in start_thread () from /lib/libpthread.so.0 #18 0x00bc2dbe in clone () from /lib/libc.so.6 It seems that a JVM thread is spinning while doing some CMS related work. We have checked the memory usage on the box, there seems to be enough memory available and the system is not swapping. Has anyone come across such a situation? Does it look like a JVM bug? UPDATE I've obtained some more information about this problem (it happened again on a server that has been running for more than 7 days). When the JVM entered the "hung" state it stayed like that for 2 hours until the server was manually restarted. We have obtained a core dump of the process and the gc log. We tried to get a heap dump as well, but "jmap" failed. We tried to use jmap -F but then only a 4Mb file was written before the program aborted with an exception (something about the a memory location not being accessible). So far I think the most interesting information comes from the gc log. It seems that the GC logging stopped as well (possibly at the time when the VM thread went into the long loop): 657501.199: [Full GC (System) 657501.199: [CMS: 400352K->313412K(524288K), 2.4024120 secs] 660634K->313412K(878208K), [CMS Perm : 29455K->29320K(68568K)], 2.4026470 secs] [Times: user=2.39 sys=0.01, real=2.40 secs] 657513.941: [GC 657513.941: [ParNew: 314624K->13999K(353920K), 0.0228180 secs] 628036K->327412K(878208K), 0.0230510 secs] [Times: user=0.08 sys=0.00, real=0.02 secs] 657523.772: [GC 657523.772: [ParNew: 328623K->17110K(353920K), 0.0244910 secs] 642036K->330523K(878208K), 0.0247140 secs] [Times: user=0.08 sys=0.00, real=0.02 secs] 657535.473: [GC 657535.473: [ParNew: 331734K->20282K(353920K), 0.0259480 secs] 645147K->333695K(878208K), 0.0261670 secs] [Times: user=0.11 sys=0.00, real=0.02 secs] .... .... 688346.765: [GC [1 CMS-initial-mark: 485248K(524288K)] 515694K(878208K), 0.0343730 secs] [Times: user=0.03 sys=0.00, real=0.04 secs] 688346.800: [CMS-concurrent-mark-start] 688347.964: [CMS-concurrent-mark: 1.083/1.164 secs] [Times: user=2.52 sys=0.09, real=1.16 secs] 688347.964: [CMS-concurrent-preclean-start] 688347.969: [CMS-concurrent-preclean: 0.004/0.005 secs] [Times: user=0.00 sys=0.01, real=0.01 secs] 688347.969: [CMS-concurrent-abortable-preclean-start] CMS: abort preclean due to time 688352.986: [CMS-concurrent-abortable-preclean: 2.351/5.017 secs] [Times: user=3.83 sys=0.38, real=5.01 secs] 688352.987: [GC[YG occupancy: 297806 K (353920 K)]688352.987: [Rescan (parallel) , 0.1815250 secs]688353.169: [weak refs processing, 0.0312660 secs] [1 CMS-remark: 485248K(524288K)] 783055K(878208K), 0.2131580 secs] [Times: user=1.13 sys =0.00, real=0.22 secs] 688353.201: [CMS-concurrent-sweep-start] 688353.903: [CMS-concurrent-sweep: 0.660/0.702 secs] [Times: user=0.91 sys=0.07, real=0.70 secs] 688353.903: [CMS-concurrent-reset-start] 688353.912: [CMS-concurrent-reset: 0.008/0.008 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] 688354.243: [GC 688354.243: [ParNew: 344928K->30151K(353920K), 0.0305020 secs] 681955K->368044K(878208K), 0.0308880 secs] [Times: user=0.15 sys=0.00, real=0.03 secs] .... .... 688943.029: [GC 688943.029: [ParNew: 336531K->17143K(353920K), 0.0237360 secs] 813250K->494327K(878208K), 0.0241260 secs] [Times: user=0.10 sys=0.00, real=0.03 secs] 688950.620: [GC 688950.620: [ParNew: 331767K->22442K(353920K), 0.0344110 secs] 808951K->499996K(878208K), 0.0347690 secs] [Times: user=0.11 sys=0.00, real=0.04 secs] 688956.596: [GC 688956.596: [ParNew: 337064K->37809K(353920K), 0.0488170 secs] 814618K->515896K(878208K), 0.0491550 secs] [Times: user=0.18 sys=0.04, real=0.05 secs] 688961.470: [GC 688961.471: [ParNew (promotion failed): 352433K->332183K(353920K), 0.1862520 secs]688961.657: [CMS I suspect this problem has something to do with the last line in the log (I've added some "...." in order to skip some lines that were not interesting). The fact that the server stayed in the hung state for 2 hours (probably trying to GC and compact the old generation) seems quite strange to me. Also, the gc log stops suddenly with that message and nothing else gets printed any more, probably because the VM Thread gets into some sort of infinite loop (or something that takes 2+ hours).

    Read the article

  • Problem in running boost eample blocking_udp_echo_client on MacOSX

    - by n179911
    I am trying to run blocking_udp_echo_client on MacOS X http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/example/echo/blocking_udp_echo_client.cpp I run it with argument 'localhost 9000' But the program crashes and this is the line in the source which crashes: `udp::socket s(io_service, udp::endpoint(udp::v4(), 0));' this is the stack trace: #0 0x918c3e42 in __kill #1 0x918c3e34 in kill$UNIX2003 #2 0x9193623a in raise #3 0x91942679 in abort #4 0x940d96f9 in __gnu_debug::_Error_formatter::_M_error #5 0x0000e76e in __gnu_debug::_Safe_iterator::op_base* , __gnu_debug_def::list::op_base*, std::allocator::op_base* ::_Safe_iterator at safe_iterator.h:124 #6 0x00014729 in boost::asio::detail::hash_map::op_base*::bucket_type::bucket_type at hash_map.hpp:277 #7 0x00019e97 in std::_Construct::op_base*::bucket_type, boost::asio::detail::hash_map::op_base*::bucket_type at stl_construct.h:81 #8 0x0001a457 in std::__uninitialized_fill_n_aux::op_base*::bucket_type*, __gnu_norm::vector::op_base*::bucket_type, std::allocator::op_base*::bucket_type , unsigned long, boost::asio::detail::hash_map::op_base*::bucket_type at stl_uninitialized.h:194 #9 0x0001a4e1 in std::uninitialized_fill_n::op_base*::bucket_type*, __gnu_norm::vector::op_base*::bucket_type, std::allocator::op_base*::bucket_type , unsigned long, boost::asio::detail::hash_map::op_base*::bucket_type at stl_uninitialized.h:218 #10 0x0001a509 in std::__uninitialized_fill_n_a::op_base*::bucket_type*, __gnu_norm::vector::op_base*::bucket_type, std::allocator::op_base*::bucket_type , unsigned long, boost::asio::detail::hash_map::op_base*::bucket_type, boost::asio::detail::hash_map::op_base*::bucket_type at stl_uninitialized.h:310 #11 0x0001aa34 in __gnu_norm::vector::op_base*::bucket_type, std::allocator::op_base*::bucket_type ::_M_fill_insert at vector.tcc:365 #12 0x0001acda in __gnu_norm::vector::op_base*::bucket_type, std::allocator::op_base*::bucket_type ::insert at stl_vector.h:658 #13 0x0001ad81 in __gnu_norm::vector::op_base*::bucket_type, std::allocator::op_base*::bucket_type ::resize at stl_vector.h:427 #14 0x0001ae3a in __gnu_debug_def::vector::op_base*::bucket_type, std::allocator::op_base*::bucket_type ::resize at vector:169 #15 0x0001b7be in boost::asio::detail::hash_map::op_base*::rehash at hash_map.hpp:221 #16 0x0001bbeb in boost::asio::detail::hash_map::op_base*::hash_map at hash_map.hpp:67 #17 0x0001bc74 in boost::asio::detail::reactor_op_queue::reactor_op_queue at reactor_op_queue.hpp:42 #18 0x0001bd24 in boost::asio::detail::kqueue_reactor::kqueue_reactor at kqueue_reactor.hpp:86 #19 0x0001c000 in boost::asio::detail::service_registry::use_service at service_registry.hpp:109 #20 0x0001c14d in boost::asio::use_service at io_service.ipp:195 #21 0x0001c26d in boost::asio::detail::reactive_socket_service ::reactive_socket_service at reactive_socket_service.hpp:111 #22 0x0001c344 in boost::asio::detail::service_registry::use_service at service_registry.hpp:109 #23 0x0001c491 in boost::asio::use_service at io_service.ipp:195 #24 0x0001c4d5 in boost::asio::datagram_socket_service::datagram_socket_service at datagram_socket_service.hpp:95 #25 0x0001c59e in boost::asio::detail::service_registry::use_service at service_registry.hpp:109 #26 0x0001c6eb in boost::asio::use_service at io_service.ipp:195 #27 0x0001c711 in boost::asio::basic_io_object ::basic_io_object at basic_io_object.hpp:72 #28 0x0001c783 in boost::asio::basic_socket ::basic_socket at basic_socket.hpp:108 #29 0x0001c865 in boost::asio::basic_datagram_socket ::basic_datagram_socket at basic_datagram_socket.hpp:107 #30 0x000027bc in main at main.cpp:32 This is the gdb output: (gdb) continue /Developer/SDKs/MacOSX10.5.sdk/usr/include/c++/4.0.0/debug/safe_iterator.h:127: error: attempt to copy-construct an iterator from a singular iterator. Objects involved in the operation: iterator "this" @ 0x0x100420 { type = N11__gnu_debug14_Safe_iteratorIN10__gnu_norm14_List_iteratorISt4pairIiPN5boost4asio6detail16reactor_op_queueIiE7op_baseEEEEN15__gnu_debug_def4listISB_SaISB_EEEEE (mutable iterator); state = singular; } iterator "other" @ 0x0xbfffe8a4 { type = N11__gnu_debug14_Safe_iteratorIN10__gnu_norm14_List_iteratorISt4pairIiPN5boost4asio6detail16reactor_op_queueIiE7op_baseEEEEN15__gnu_debug_def4listISB_SaISB_EEEEE (mutable iterator); state = singular; } Program received signal: “SIGABRT”. (gdb) continue Program received signal: “?”. Does someone has any idea why this example does not work on mac osx? Thank you.

    Read the article

  • ./a.out termniated . Garbage output due to smashing of stack . How to remove this error ?

    - by mekasperasky
    #include <iostream> #include <fstream> #include <cstring> using namespace std; typedef unsigned long int WORD; /* Should be 32-bit = 4 bytes */ #define w 32 /* word size in bits */ #define r 12 /* number of rounds */ #define b 16 /* number of bytes in key */ #define c 4 /* number words in key */ /* c = max(1,ceil(8*b/w)) */ #define t 26 /* size of table S = 2*(r+1) words */ WORD S [t],L[c]; /* expanded key table */ WORD P = 0xb7e15163, Q = 0x9e3779b9; /* magic constants */ /* Rotation operators. x must be unsigned, to get logical right shift*/ #define ROTL(x,y) (((x)<<(y&(w-1))) | ((x)>>(w-(y&(w-1))))) #define ROTR(x,y) (((x)>>(y&(w-1))) | ((x)<<(w-(y&(w-1))))) void RC5_ENCRYPT(WORD *pt, WORD *ct) /* 2 WORD input pt/output ct */ { WORD i, A=pt[0]+S[0], B=pt[1]+S[1]; for (i=1; i<=r; i++) { A = ROTL(A^B,B)+S[2*i]; B = ROTL(B^A,A)+S[2*i+1]; } ct [0] = A ; ct [1] = B ; } void RC5_DECRYPT(WORD *ct, WORD *pt) /* 2 WORD input ct/output pt */ { WORD i, B=ct[1], A=ct[ 0]; for (i=r; i>0; i--) { B = ROTR(B-S [2*i+1],A)^A; A = ROTR(A-S [2*i],B)^B; } pt [1] = B-S [1] ;pt [0] = A-S [0]; } void RC5_SETUP(unsigned char *K) /* secret input key K 0...b-1] */ { WORD i, j, k, u=w/8, A, B, L [c]; /* Initialize L, then S, then mix key into S */ for (i=b-1,L[c-1]=0; i!=-1; i--) L[i/u] = (L[i/u]<<8)+K[ i]; for (S [0]=P,i=1; i<t; i++) S [i] = S [i-1]+Q; for (A=B=i=j=k=0; k<3*t; k++,i=(i+1)%t,j=(j+1)%c) /* 3*t > 3*c */ { A = S[i] = ROTL(S [i]+(A+B),3); B = L[j] = ROTL(L[j]+(A+B),(A+B)); } } void printword(WORD A) { WORD k; for (k=0 ;k<w; k+=8) printf("%c"); } int main() { WORD i, j, k,ptext, pt1 [2], pt2 [2], ct [2] = {0,0}; ifstream in("key1.txt"); ifstream in1("plt.txt"); ofstream out1("cpt.txt"); if(!in) { cout << "Cannot open file.\n"; return 1; } if(!in1) { cout << "Cannot open file.\n"; return 1; } unsigned char key[b]; in >> key; in1 >> pt1[0]; in1 >> pt1[0]; if (sizeof(WORD)!=4) printf("RC5 error: WORD has %d bytes.\n",sizeof(WORD)); RC5_SETUP(key); RC5_ENCRYPT(pt1,ct); printf("\n plaintext "); printword(pt1 [0]); printword(pt1 [1]); printf(" ---> ciphertext "); printword(ct [0]); printword(ct [1]); printf("\n"); RC5_SETUP(key); RC5_DECRYPT(ct,pt2); out1<<ct[0]; out1<<ct[1]; out1 <<"\n"; printf("\n plaintext "); printword(pt1 [0]); printword(pt1 [1]); return 0; } Let the plt.txt file contain 101 100 let the key be 111

    Read the article

  • Why index_merge is not used here?

    - by user198729
    Setup: mysql> create table t(a integer unsigned,b integer unsigned); mysql> insert into t(a,b) values (1,2),(1,3),(2,4); mysql> create index i_t_a on t(a); mysql> create index i_t_b on t(b); mysql> explain select * from t where a=1 or b=4; +----+-------------+-------+------+---------------+------+---------+------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+------+---------------+------+---------+------+------+-------------+ | 1 | SIMPLE | t | ALL | i_t_a,i_t_b | NULL | NULL | NULL | 3 | Using where | +----+-------------+-------+------+---------------+------+---------+------+------+-------------+ Is there something I'm missing?

    Read the article

< Previous Page | 81 82 83 84 85 86 87 88 89 90 91 92  | Next Page >