Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

CÖÐmallocºÍfreeµÄÔ­Àí Õª×Ôtechriver.cublog.cn

̸̸CÓïÑÔµÄmalloc()ºÍfree()
Ò»¡¢malloc()ºÍfree()µÄ»ù±¾¸ÅÄîÒÔ¼°»ù±¾Ó÷¨£º
1¡¢º¯ÊýÔ­Ðͼ°ËµÃ÷£º
void *malloc(long NumBytes)£º¸Ãº¯Êý·ÖÅäÁËNumBytes¸ö×Ö½Ú£¬²¢·µ»ØÁËÖ¸ÏòÕâ¿éÄÚ´æµÄÖ¸Õë¡£Èç¹û·ÖÅäʧ°Ü£¬Ôò·µ»ØÒ»¸ö¿ÕÖ¸Õ루NULL£©¡£
¹ØÓÚ·ÖÅäʧ°ÜµÄÔ­Òò£¬Ó¦¸ÃÓжàÖÖ£¬±ÈÈç˵¿Õ¼ä²»×ã¾ÍÊÇÒ»ÖÖ¡£
void free(void *FirstByte)£º ¸Ãº¯ÊýÊǽ«Ö®Ç°ÓÃmalloc·ÖÅäµÄ¿Õ¼ä»¹¸ø³ÌÐò»òÕßÊDzÙ×÷ϵͳ£¬Ò²¾ÍÊÇÊÍ·ÅÁËÕâ¿éÄڴ棬ÈÃËüÖØеõ½×ÔÓÉ¡£
2¡¢º¯ÊýµÄÓ÷¨£º
     ÆäʵÕâÁ½¸öº¯ÊýÓÃÆðÀ´µ¹²»ÊǺÜÄÑ£¬Ò²¾ÍÊÇmalloc()Ö®ºó¾õµÃÓù»Á˾Í˦ÁËËü°ÑËü¸øfree()ÁË£¬¾Ù¸ö¼òµ¥Àý×Ó£º
³ÌÐò´úÂ룺
        // Code...
        char *Ptr = NULL;
        Ptr = (char *)malloc(100 * sizeof(char));
        if (NULL == Ptr)
    {
        exit (1);
    }
        gets(Ptr);
        // code...
        free(Ptr);
        Ptr = NULL;
        // code...
    ¾ÍÊÇÕâÑù£¡µ±È»£¬¾ßÌåÇé¿öÒª¾ßÌå·ÖÎöÒÔ¼°¾ßÌå½â¾ö¡£±ÈÈç˵£¬Ä㶨ÒåÁËÒ»¸öÖ¸Õ룬ÔÚÒ»¸öº¯ÊýÀïÉêÇëÁËÒ»¿éÄÚ´æÈ»ºóͨ¹ýº¯Êý·µ»Ø´«µÝ¸øÕâ¸öÖ¸Õ룬ÄÇôҲÐíÊÍ·ÅÕâ¿éÄÚ´æÕâÏ×÷¾ÍÓ¦¸ÃÁô¸øÆäËûº¯ÊýÁË¡£
3¡¢¹ØÓÚº¯ÊýʹÓÃÐèҪעÒâµÄһЩµØ·½£º
A¡¢ÉêÇëÁËÄÚ´æ¿Õ¼äºó£¬±ØÐë¼ì²éÊÇ·ñ·ÖÅä³É¹¦¡£
B¡¢µ±²»ÐèÒªÔÙʹÓÃÉêÇëµÄÄÚ´æʱ£¬¼ÇµÃÊÍ·Å£»ÊͷźóÓ¦¸Ã°ÑÖ¸ÏòÕâ¿éÄÚ´æµÄÖ¸ÕëÖ¸ÏòNULL£¬·ÀÖ¹³ÌÐòºóÃ治СÐÄʹÓÃÁËËü¡£
C¡¢ÕâÁ½¸öº¯ÊýÓ¦¸ÃÊÇÅä¶Ô¡£Èç¹ûÉêÇëºó²»ÊͷžÍÊÇÄÚ´æй¶£»Èç¹ûÎÞ¹ÊÊÍ·ÅÄǾÍÊÇʲôҲûÓÐ×ö¡£ÊÍ·ÅÖ»ÄÜÒ»´Î£¬Èç¹ûÊÍ·ÅÁ½´Î¼°Á½´ÎÒÔÉÏ»á
³öÏÖ´íÎó£¨ÊÍ·Å¿ÕÖ¸ÕëÀýÍ⣬ÊÍ·Å¿ÕÖ¸ÕëÆäʵҲµÈÓÚɶҲû×ö£¬ËùÒÔÊÍ·Å¿ÕÖ¸ÕëÊͷŶàÉٴζ¼Ã»ÓÐÎÊÌ⣩¡£
D¡¢ËäÈ»malloc()º¯ÊýµÄÀàÐÍÊÇ(void *),ÈκÎÀàÐ͵ÄÖ¸Õ붼¿ÉÒÔת»»³É(void *),µ«ÊÇ×îºÃ»¹ÊÇÔÚÇ°Ãæ½øÐÐÇ¿ÖÆÀàÐÍת»»£¬ÒòΪÕâÑù¿ÉÒÔ¶ã¹ýÒ»
Щ±àÒëÆ÷µÄ¼ì²é¡£
ºÃÁË£¡×î»ù´¡µÄ¶«Î÷´ó¸ÅÕâô


Ïà¹ØÎĵµ£º

LinuxÏÂCºÍC++¿ª·¢»ù´¡

LinuxÏÂCºÍC++¿ª·¢»ù´¡
»ù±¾±à³Ì¸ÅÄî
n ±à³ÌÓïÑÔ£ºC ¡¢C++
n ±àÒë(compile)£ºÔ´Îļþ£¨.c£©->Ä¿±êÎļþ(.o)
n Á¬½Ó(link)£ºÄ¿±êÎļþ(.o)->¿ÉÖ´ÐÐÎļþ
n ¿â(library)£º¾²Ì¬Á¬½Ó¿â(.a)¡¢¶¯Ì¬Á¬½Ó¿â(.so)
LinuxÏ¿ª·¢¹¤¾ß
n±à¼­Æ÷£ºvi¡¢emacs¡¢´°¿Ú±à¼­Æ÷
n±àÒëÆ÷£ºGCC
nµ÷ÊÔÆ÷£ºGDB
n¿ÉÖ´ÐÐÎļþ¹¤¾ß£ ......

perlembed ÔÚ C ³ÌÐòÖÐǶÈë perl

NAME
    perlembed - ÔÚ C ³ÌÐòÖÐǶÈë perl
DESCRIPTION
  µ¼ÑÔ
    ÄãÊÇÏëÒª£º
    ÔÚ Perl ÖÐʹÓà C£¿
         ÔĶÁ perlxstut¡¢perlxs¡¢h2xs¡¢perlguts ºÍ perlapi¡£
    ÔÚ Perl ÖÐʹÓà Unix ³ÌÐò£¿
     & ......

linux 0.11 ÄÚºËѧϰ floppy.c£¬Çý¶¯ÄãµÄÈíÅÌ


/*
 *  linux/kernel/floppy.c
 *
 *  (C) 1991  Linus Torvalds
 */
/*
 * 02.12.91 - Changed to static variables to indicate need for reset
 * and recalibrate. This makes some things easier (output_byte reset
 * checking etc), and means less i ......

C++ÖÐextern ¡°C¡±º¬ÒåÉî²ã̽Ë÷(ÔÚÔ­×÷µÄ»ù´¡ÉÏÐ޸ģ©


1.
ÒýÑÔ
¡¡¡¡C++
ÓïÑԵĴ´½¨³õÖÔÊÇ“a
better C”
£¬µ«ÊÇÕâ²¢²»Òâζ×ÅC++
ÖÐÀàËÆC
ÓïÑÔµÄÈ«¾Ö±äÁ¿ºÍº¯ÊýËù²ÉÓõıàÒëºÍÁ¬½Ó·½Ê½ÓëC
ÓïÑÔÍêÈ«Ïàͬ¡£×÷ΪһÖÖÓûÓëC
¼æÈݵÄÓïÑÔ£¬C++
±£ÁôÁËÒ»²¿·Ö¹ý³Ì ʽÓïÑÔµÄÌص㣨±»ÊÀÈ˳ÆΪ“
²»³¹µ×µØÃæÏò¶ÔÏó”
£©£¬Òò¶øËü¿ÉÒÔ¶¨Òå²»ÊôÓÚÈκÎÀàµÄÈ«¾Ö ......

Symbian C/S »úÖÆ·ÖÎö


ÒÔÏ·ÖÎö»ùÓÚ£º
Developer Platform :S60 3rd Edition, Feature Pack 2 SDK
Operating System :Symbian OS v9.3
Ò»£¬ÎªÊ²Ã´ÒªÊ¹ÓÃClient/Server¼Ü¹¹
ÔÚSymibian OSÖÐËùÓеÄÒì²½·þÎñ¶¼ÊÇServerͨ¹ýC/S¼Ü¹¹À´ÊµÏֵġ£ClientÊÇÀûÓÃServerÌṩµÄÌض¨·þÎñµÄ³ÌÐò£¬Server½ÓÊÜÀ´ÖÁClientµÄÇëÇóÏûÏ¢²¢Í¬²½»òÒì²½µÄ´¦ÀíËûÃÇ¡£C ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ