Scroll to navigation

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;

°ú¤­¿ô

¥Ð¥¤¥È¿ô(XtRealloc)Ëô¤ÏÇÛÎóÍ×ÁǤοô(XtCalloc)¤ò»ØÄꤹ¤ë¡£
²òÊü¤µ¤ì¤ë¸Å¤¤µ­²±Îΰè¤Ø¤Î¥Ý¥¤¥ó¥¿(XtFree)¡¢Ëô¤Ïµ­²±Îΰè¥Ö¥í¥Ã¥¯¤Ø¤Î¥Ý ¥¤¥ó¥¿(XtRealloc)¤ò»ØÄꤹ¤ë¡£
¥Ð¥¤¥Èñ°Ì¤Çɽ¤·¤¿ÇÛÎóÍ×ÁǤÎÂ礭¤µ(XtCalloc)¡¢Ëô¤ÏÍ׵᤹¤ë¥Ð¥¤¥È¿ô (XtMalloc)¤ò»ØÄꤹ¤ë¡£
´û¤ËÀë¸À¤µ¤ì¤Æ¤¤¤ëʸ»úÎó¤ò»ØÄꤹ¤ë¡£
´û¤ËÀë¸À¤µ¤ì¤Æ¤¤¤ë¥Ç¡¼¥¿·¿¤ò»ØÄꤹ¤ë¡£

ÀâÌÀ

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