XtMalloc(3Xt) | XT FUNCTIONS | XtMalloc(3Xt) |
̾Á°¶
XtMalloc, XtCalloc, XtRealloc, XtFree, XtNew, XtNewString - ¥á¥â¥ê´ÉÍýÍÑ´Ø¿ô
½ñ¼°¶
char *XtMalloc(size);
Cardinal size;
char *XtCalloc(num, size);
Cardinal num;
Cardinal size;
char *XtRealloc(ptr, num);
char *ptr;
Cardinal num;
void XtFree(ptr);
char *ptr;
type *XtNew(type);
type;
String XtNewString(string);
String string;
°ú¤¿ô¶
- num
- ¥Ð¥¤¥È¿ô(XtRealloc)Ëô¤ÏÇÛÎóÍ×ÁǤοô(XtCalloc)¤ò»ØÄꤹ¤ë¡£
- ptr
- ²òÊü¤µ¤ì¤ë¸Å¤¤µ²±Îΰè¤Ø¤Î¥Ý¥¤¥ó¥¿(XtFree)¡¢Ëô¤Ïµ²±Îΰè¥Ö¥í¥Ã¥¯¤Ø¤Î¥Ý ¥¤¥ó¥¿(XtRealloc)¤ò»ØÄꤹ¤ë¡£
- size
- ¥Ð¥¤¥Èñ°Ì¤Çɽ¤·¤¿ÇÛÎóÍ×ÁǤÎÂ礤µ(XtCalloc)¡¢Ëô¤ÏÍ׵᤹¤ë¥Ð¥¤¥È¿ô (XtMalloc)¤ò»ØÄꤹ¤ë¡£
- string
- ´û¤ËÀë¸À¤µ¤ì¤Æ¤¤¤ëʸ»úÎó¤ò»ØÄꤹ¤ë¡£
- type
- ´û¤ËÀë¸À¤µ¤ì¤Æ¤¤¤ë¥Ç¡¼¥¿·¿¤ò»ØÄꤹ¤ë¡£
ÀâÌÀ¶
XtMalloc ´Ø¿ô¤Ï»ØÄꤷ¤¿¥Ð¥¤¥È¥µ¥¤¥º¤Îµ²±Îΰè¥Ö¥í¥Ã¥¯¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£ ¤â¤·¿·¤·¤¤¥Ö¥í¥Ã¥¯¤ò³ä¤êÅö¤Æ¤ë¤³¤È¤Î¤Ç¤¤ë½½Ê¬¤Ê¥á¥â¥ê¤¬¤Ê¤¤¾ì¹ç¡¢ XtMalloc ¤Ï XtErrorMsg ¤ò¸Æ¤Ó½Ð¤¹¡£
XtCalloc ´Ø¿ô¤Ï»ØÄꤵ¤ì¤¿Â礤µ¤ÎÇÛÎóÍ×ÁǤòƱ¤¸¤¯»ØÄꤵ¤ì¤¿¿ô¤À¤±¤Î¥á¥â¥ê¤ò³ä¤ê Åö¤Æ¡¢¤½¤ÎÎΰè¤ò 0 ¤Ç½é´ü²½¤¹¤ë¡£ ¤â¤·¿·¤·¤¤¥Ö¥í¥Ã¥¯¤ò³ä¤êÅö¤Æ¤ë¤³¤È¤Î¤Ç¤¤ë½½Ê¬¤Ê¥á¥â¥ê¤¬¤Ê¤¤¾ì¹ç¡¢ XtCalloc ¤Ï XtErrorMsg ¤ò¸Æ¤Ó½Ð¤¹¡£
XtRealloc ´Ø¿ô¤Ïµ²±Îΰè¥Ö¥í¥Ã¥¯¤ÎÂ礤µ¤òÊѹ¹¤¹¤ë¡Êµ²±Îΰè¤Ï°ÜÆ°¤µ¤ì¤ë²ÄǽÀ¤¬ ¤¢¤ë¡Ë¡£ ¼¡¤Ë¿·¤·¤¤¥Ö¥í¥Ã¥¯¤Ë¸Å¤¤ÆâÍÆ¡ÊËô¤Ï¿·¤·¤¤¥Ö¥í¥Ã¥¯¤ÎÂ礤µ¤ËÆþ¤ëÆâÍơˤò Ê£¼Ì¤·¡¢¸Å¤¤¥Ö¥í¥Ã¥¯¤ò²òÊü¤¹¤ë¡£ ¤â¤·¿·¤·¤¤¥Ö¥í¥Ã¥¯¤ò³ä¤êÅö¤Æ¤ë¤³¤È¤Î¤Ç¤¤ë½½Ê¬¤Ê¥á¥â¥ê¤¬¤Ê¤¤¾ì¹ç¡¢ XtRealloc ¤Ï XtErrorMsg ¤ò¸Æ¤Ó½Ð¤¹¡£ ¤Þ¤¿ ptr ¤¬ NULL ¤Ê¤é¤Ð XtRealloc ¤Ï¸Å¤¤ÆâÍƤòÊ£¼Ì¤»¤º¤Ë¿·¤·¤¤µ²±Îΰè¤ò³ä¤êÅö¤Æ¤ë¡£ ¤Ä¤Þ¤êñ¤Ë XtMalloc ¤ò¸Æ¤Ö¤À¤±¤Ç¤¢¤ë¡£
XtFree ´Ø¿ô¤Ïµ²±Îΰè¤ò²òÊü¤·¡¢ºÆÍøÍѤǤ¤ë¤è¤¦¤Ë¤¹¤ë¡£ ¤â¤· ptr ¤¬ NULL ¤Ê¤é¤Ð XtFree ¤Ï²¿¤â¤»¤º¤Ë½ªÎ»¤¹¤ë¡£
XtNew ¤Ï³ä¤êÅö¤Æ¤é¤ì¤¿µ²±Îΰè¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£ ¤â¤·¿·¤·¤¤¥Ö¥í¥Ã¥¯¤ò³ä¤êÅö¤Æ¤ë¤³¤È¤Î¤Ç¤¤ë½½Ê¬¤Ê¥á¥â¥ê¤¬¤Ê¤¤¾ì¹ç¡¢ XtNew ¤Ï XtErrorMsg ¤ò¸Æ¤Ó½Ð¤¹¡£ XtNew ¤Ï¼¡¤Î»ØÄꤵ¤ì¤¿°ú¤¿ô¤Ç XtMalloc ¤ò¸Æ¤Ó½Ð¤¹´Ê°×¥Þ¥¯¥í¤Ç¤¢¤ë¡§
((type *) XtMalloc((unsigned) sizeof(type))
XtNewString ¤Ï³ä¤êÅö¤Æ¤é¤ì¤¿µ²±Îΰè¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£ ¤â¤·¿·¤·¤¤¥Ö¥í¥Ã¥¯¤ò³ä¤êÅö¤Æ¤ë¤³¤È¤Î¤Ç¤¤ë½½Ê¬¤Ê¥á¥â¥ê¤¬¤Ê¤¤¾ì¹ç¡¢ XtNewString ¤Ï XtErrorMsg ¤ò¸Æ¤Ó½Ð¤¹¡£ XtNewString ¤Ï¼¡¤Î»ØÄꤵ¤ì¤¿°ú¤¿ô¤Ç XtMalloc ¤ò¸Æ¤Ó½Ð¤¹´Ê°×¥Þ¥¯¥í¤Ç¤¢¤ë¡§
(strcpy(XtMalloc((unsigned) strlen(str) + 1), str))
´ØÏ¢¹àÌܶ
X
¥Ä¡¼¥ë¥¥Ã¥È
¥¤¥ó¥È¥ê¥ó¥·¥¯¥¹
- C
¸À¸ì¥¤¥ó¥¿¡¼¥Õ¥§¥¤¥¹
Xlib - C ¸À¸ì X
¥¤¥ó¥¿¡¼¥Õ¥§¥¤¥¹
Release 6.5 | X Version 11 |