[ CnUnix ] in KIDS ±Û ¾´ ÀÌ(By): guest (guest) <211.38.42.81> ³¯ Â¥ (Date): 2002³â 7¿ù 30ÀÏ È­¿äÀÏ ¿ÀÈÄ 06½Ã 12ºÐ 29ÃÊ Á¦ ¸ñ(Title): ÇÁ·Î±×·¥ÀÇ ¸Þ¸ð¸® »ç¿ë·® Áõ°¡.. ¸®´ª½º¿¡¼­ C·Î ÇÁ·Î±×·¥À» ÀÛ¼ºÇߴµ¥ ¸î ½Ã°£µ¿¾È °è¼Ó ½ÇÇà½ÃÄÑ ³õÀº ÈÄ ¸Þ¸ð¸® »ç¿ë·®(top ¸í·ÉÀ¸·Î..)À» º¸¸é ²ÙÁØÈ÷ Áõ°¡ÇÏ°í ÀÖ½À´Ï´Ù. mallocÀ» ¾²´Â ºÎºÐÀ» º¸¸é ´Ù¸¥µ¥·Î ºÐ±âÇÏ´Â µ¥µµ ¾ø°í ¼Ò½º»óÀ¸·Î´Â È®½ÇÈ÷ free()¸¦ ½ÇÇà½Ãŵ´Ï´Ù. (ÇÔ¼ö Áß°£¿¡ returnÀÌ ¾ø°í Á¾·áÀü¿¡ free()¸¦ È£ÃâÇÏ´Ï...) ±×·±µ¥µµ °è¼Ó ¸Þ¸ð¸® »ç¿ë·üÀÌ Áõ°¡ÇÏ´Â ÀÌÀ¯°¡ ¹»±î¿ä? ¾Æ·¡¿Í °°Àº Äڵ尡 ¹®Á¦°¡ µÉ±î¿ä? char *str_ret() { static char buf[512]; ... return buf; } ... func2() { char *test; .... test=str_ret(); ... } À̶§ func2°¡ ¿©·¯¹ø È£ÃâµÇ¸é ¸Þ¸ð¸®°¡ »ø±î¿ä? [ CnUnix ] in KIDS ±Û ¾´ ÀÌ(By): flesh (t(-_-t);;) ³¯ Â¥ (Date): 2002³â 7¿ù 30ÀÏ È­¿äÀÏ ¿ÀÈÄ 08½Ã 40ºÐ 47ÃÊ Á¦ ¸ñ(Title): Re: ÇÁ·Î±×·¥ÀÇ ¸Þ¸ð¸® »ç¿ë·® Áõ°¡.. ¼³¸¶.. ¹è¿­¿¡ free()??? [ CnUnix ] in KIDS ±Û ¾´ ÀÌ(By): kimsr (Pabochet) ³¯ Â¥ (Date): 2002³â 7¿ù 30ÀÏ È­¿äÀÏ ¿ÀÈÄ 08½Ã 48ºÐ 43ÃÊ Á¦ ¸ñ(Title): Re: ÇÁ·Î±×·¥ÀÇ ¸Þ¸ð¸® »ç¿ë·® Áõ°¡.. ±×°É·Î´Â ¾È»õ´Â µ¥¿©. [ CnUnix ] in KIDS ±Û ¾´ ÀÌ(By): kimsr (Pabochet) ³¯ Â¥ (Date): 2002³â 7¿ù 30ÀÏ È­¿äÀÏ ¿ÀÈÄ 08½Ã 48ºÐ 43ÃÊ Á¦ ¸ñ(Title): Re: ÇÁ·Î±×·¥ÀÇ ¸Þ¸ð¸® »ç¿ë·® Áõ°¡.. ±×°É·Î´Â ¾È»õ´Â µ¥¿©. [ CnUnix ] in KIDS ±Û ¾´ ÀÌ(By): ahsarang (.¾Æ.»ç.¶û.) ³¯ Â¥ (Date): 2002³â 7¿ù 30ÀÏ È­¿äÀÏ ¿ÀÈÄ 09½Ã 39ºÐ 39ÃÊ Á¦ ¸ñ(Title): Re: ÇÁ·Î±×·¥ÀÇ ¸Þ¸ð¸® »ç¿ë·® Áõ°¡.. malloc»ç¿ëÀº ¾îµð¼­ Çϴµ¥¿ä? -.- [ CnUnix ] in KIDS ±Û ¾´ ÀÌ(By): guest (guest) <218.146.62.186> ³¯ Â¥ (Date): 2002³â 7¿ù 30ÀÏ È­¿äÀÏ ¿ÀÈÄ 10½Ã 38ºÐ 52ÃÊ Á¦ ¸ñ(Title): Re: ÇÁ·Î±×·¥ÀÇ ¸Þ¸ð¸® »ç¿ë·® Áõ°¡.. ¿ì~ Àú Äڵ忡 mallocÀ» ½è´Ù´Â°Ô ¾Æ´Ï°í¿ä... mallocÀº ´Ù¸¥ ±â´ÉÀÇ ÇÔ¼ö¿¡¼­ »ç¿ëÀ» Çß°í Á¦°¡ º¼¶§´Â ÇнÇÈ÷ ¹Ý³³À» Çß½À´Ï´Ù. ¹°·Ð ¹è¿­À» freeÇÑ °Íµµ ¾Æ´Ï°í.. ¹ÌõÇÑ Áö½ÄÀ¸·Î ±× ¿ÜÀÇ ¿øÀÎÀ» ãÀÚ´Ï 1¸¸ºÐÀÇ1ÀÇ ±â´ë°ªÀ¸·Î À§ ÄÚµå ¹æ½Ä¿¡ ¹®Á¦°¡ ÀÖ³ª ÀǽÉÇѰŶ󱸿ä. -_-; malloc À» ¾´ ºÎºÐÀº ¸î½ÊÁÙ µÇÁöµµ ¾ÊÀº ±æÀÌÀ̱⠶§¹®¿¡ ¿À·ù°¡ ³¯ ÅÎÀÌ ¾ø°í. libpcapÇÏ°í mysqlclient library¸¦ »ç¿ëÇϴµ¥ À̵¡µé¿¡ ´ëÇÑ ¹ö±×°¡ ¾ø³ª ÀÎÅÍ³Ý µÚÁö°í ÀÖ½À´Ï´Ù. Ȥ½Ã mysql ÇÔ¼ö ¾²°í free()ÇØ Áà¾ß µÈ´Â °Íµµ ÀÖ³ª¿ä? mysql_queryÀÇ °á°úÄ¡ °°Àº°Å... [ CnUnix ] in KIDS ±Û ¾´ ÀÌ(By): flesh (t(-_-t);;) ³¯ Â¥ (Date): 2002³â 7¿ù 30ÀÏ È­¿äÀÏ ¿ÀÈÄ 10½Ã 57ºÐ 11ÃÊ Á¦ ¸ñ(Title): Re: ÇÁ·Î±×·¥ÀÇ ¸Þ¸ð¸® »ç¿ë·® Áõ°¡.. ¹ßÃé http://www.strath.ac.uk --- Another class of local variable is the static type. A static can only be accessed from the function in which it was declared, like a local variable. The static variable is not destroyed on exit from the function, instead its value is preserved, and becomes available again when the function is next called. Static variables are declared as local variables, but the declaration is preceeded by the word static. static int counter; Static variables can be initialised as normal, the initialisation is performed once only, when the program starts up. --- staticÀº local scope ¸¦ °®Áö¸¸, ±× ¸Þ¸ð¸®ÀÇ release´Â exit ¼ø°£ÀÔ´Ï´Ù. ¶ÇÇÑ º¹¼ö¹ø call µÇ¾ú´Ù°í Çؼ­, °è¼Ó ÀâÈ÷´Â °ÍÀÌ ¾Æ´Ï¶ó, exit ¼ø°£±îÁö µ¿ÀÏÇÑ ¿µ¿ªÀÌ À¯ÁöµÇÁö¿ä. --- Àú functionÀ» °è¼Ó fork() ÇϽÅÈÄ ½ÇÇàÇϽʴϱî? ÀÚ·á°¡ ºÎÁ·½º·¯¿îµí... :) Âü°í·Î ÀúÀÇ ¹ÌõÇÑ ¼Ò°ßÀ¸·Î, thread ¿¡¼± static °ø°£ÀÌ °øÀ¯µÇ¼­ ¿ÀÈ÷·Á synchronizationÀÌ ÇÊ¿äÇÏ´Ù°í º¾´Ï´Ù. [ CnUnix ] in KIDS ±Û ¾´ ÀÌ(By): flesh (t(-_-t);;) ³¯ Â¥ (Date): 2002³â 7¿ù 30ÀÏ È­¿äÀÏ ¿ÀÈÄ 11½Ã 05ºÐ 23ÃÊ Á¦ ¸ñ(Title): Re: ÇÁ·Î±×·¥ÀÇ ¸Þ¸ð¸® »ç¿ë·® Áõ°¡.. Äõ¸® °á°úÄ¡ ¾²°í ´ç¿¬È÷ free()°úÁ¤ÀÌ ÀÖ¾î¾ß ÇÒ µí ½ÍÀºµ¥¿ä. °á°úÄ¡¶ó ¸»¾¸ÇϽô °ÍÀº ResultSet (in java)ÀÌ ºÐ¸íÇѵ¥, ÀÌ·± °ø°£µéÀº DB call ÇÏ°í ³­ ´ÙÀ½¿¡ ¹ß»ýÇÏ°ÚÁÒ? ±×·³ malloc() °°Àº °ÍÀ¸·Î ÀâÀ»°Ô ºÐ¸íÇÒ °Í °°½À´Ï´Ù. ±¦½Ã¸® array·Î ±¸¼ºÇß´Ù°¡ dangling pointer Çö»óÀ» ¸¸³¯¼öµµ ÀÖ°í ºÐ¸íÇÏ°Ô, malloc()¸ÞÄ¿´ÏÁò ÀÌ¿ëÇßÀ» Å×°í, ±×·¸°Ô µÇ¸é ÀûüµË´Ï´Ù. ¸Þ¸ð¸®. mysql API¿¡¼­ ÀÌ·± ºÎºÐÀÌ ÀÖÀ»ÅÙµ¥..... ÀÚ¹Ù°°Àº °÷¿¡¼­¾ß Àú·±°ÆÁ¤¾ÈÇصµ µÇÁö¸¸, C¿¡¼± ¹®Á¦°¡ µÉ°Í °°½À´Ï´Ù. ±× ResultSetÀ̶õ ³ðÀÌ ¾Æ·¡ °°Àº ³ðÀÏ °Í °°Àºµ¥... -- This is a type-safe representation of one row of data. It is currently implemented as an array of counted byte strings. (You cannot treat these as null-terminated strings if field values may contain binary data, because such values may contain null bytes internally.) Rows are obtained by calling mysql_fetch_row(). -- fetch_row()´Â DBÀÇ row¸¦ ±×´ë·Î °¡Á®¿À´Â ¿ªÇÒÀ» ÇÏÁö¿ä. ¿©±â¼­ ÀûÀýÇÑ cast °¡ ÇÊ¿äÇÏ°í... (¾Æ¸¶ ¿ä³ðÀº ÀûÀýÈ÷ getÇÏ´Â °Ô ÀÖ°ÚÁö¿ä.) ±×¸®°í ±×·± resultset¿¡ ´ëÇÑ release´Â ´ÙÀ½ÀÇ function¿¡ ¸í½ÃµÇ¾î ÀÖ½À´Ï´Ù. -- mysql_free_result() Frees memory used by a result set. -- free ¾ÈÇØÁ൵ µÈ´Ù! ¶ó´Â ¸»ÀÌ ¾øÀ¸¸é free()ÇØÁÖ´Â °Ô »ó½ÄÀÏ °Í °°½À´Ï´Ù. µ¥ÀÌÅÍ Çü ¼±¾ðÇØÁÖ°í Á¤ÀǸ¦ ³»·È´Ù°í memory ÀâÈ÷´Â °ÍÀº ¾Æ´ÒÅ×°í, ±×·¯´Ï õ »ó ³»ºÎÀûÀÎ logicÀº malloc()/free() ÀÏ °Í °°½À´Ï´Ù. -- After you are done with a result set, call mysql_free_result() to free the memory used for it. mysql_free_result() void mysql_free_result(MYSQL_RES *result) Description Frees the memory allocated for a result set by mysql_store_result(), mysql_use_result(), mysql_list_dbs(), etc. When you are done with a result set, you must free the memory it uses by calling mysql_free_result(). Return Values None. -- ¿ª½Ã °ü·Ã ³»¿ëÀÌ ÀÖ±º¿ä. Á¶±â~ must free º¸À̽ÃÁÒ? :) À̳𠹮Á¦ÀÏ ¼ö ÀÖÀ» ¼öµµ! ³Ê¹« ½¬¿î ³»¿ëÀ» ÀÏÀÏÈ÷ ã¾Æ°¡¸é¼­ comment ÇÏ´À¶ó ±æ¾îÁ³½À´Ï´Ù. °³¶±°°Àº ÄÚ¸àÆ® Àß º¸½Ã±æ. :) http://www.mysql.com/documentation/mysql/full/index.html ¿©±â¼­ ÂüÁ¶Çß½À´Ï´Ù. [ CnUnix ] in KIDS ±Û ¾´ ÀÌ(By): terzeron (microkid) ³¯ Â¥ (Date): 2002³â 7¿ù 31ÀÏ ¼ö¿äÀÏ ¿ÀÀü 09½Ã 57ºÐ 38ÃÊ Á¦ ¸ñ(Title): Re: ÇÁ·Î±×·¥ÀÇ ¸Þ¸ð¸® »ç¿ë·® Áõ°¡.. mysqlclient ¶óÀ̺귯¸®·Î API ÇÁ·Î±×·¡¹ÖÀ» Çϼ̴ٸé mysql_store_result()³ª mysql_use_result(), mysql_list_dbs()µîÀÇ ÇÔ¼ö »ç¿ë ÀÌÈÄ¿¡ mysql_free_result()¸¦ ÇØÁÖ¼Å¾ß ÇÕ´Ï´Ù. staticÀº flesh´Ô²²¼­µµ ¸»¾¸Çϼ̴ٽÃÇÇ ¹®Á¦¾ø´Â °Í °°½À´Ï´Ù. ±×¸®°í -g ¿É¼ÇÀ» ÄÑ°í ÄÄÆÄÀÏÇϽŠ´ÙÀ½¿¡ gdb ¾È¿¡¼­ ½ÇÇàÇؼ­ ¹®Á¦°¡ »ý±â´Â Á¤È®ÇÑ À§Ä¡¸¦ ã¾Æº¸½Ã´Â °ÍÀÌ ¹®Á¦ ÇØ°áÀÇ ½Ç¸¶¸®°¡ µÉ °Í °°½À´Ï´Ù.