home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / REND.LZH / READER / ALLOC.C next >
C/C++ Source or Header  |  1996-07-11  |  15KB  |  665 lines

  1. /*
  2.  *        データ確領域処理関数
  3.  *
  4.  *            1989.12.10
  5.  *            Copyright    T.Kobayashi
  6.  *
  7.  */
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #ifdef X68000
  11. #include <doslib.h>
  12. #endif
  13. #ifdef __BORLANDC__
  14. #include <malloc.h>
  15. #include <memory.h>
  16. #include <alloc.h>
  17. #endif
  18. #ifdef MSC
  19. #include <malloc.h>
  20. #include <memory.h>
  21. #endif
  22. #include <assert.h>
  23.  
  24. #include "reader.h"
  25.  
  26. #define ALLOC_DATA_ID    12345
  27. #define ALLOC_TEMP_ID    23456
  28.  
  29. /*#define ERR(sss) {FILE *fp;fp=fopen("tmp.log","a");sss;fclose(fp);}*/
  30.  
  31. #ifndef ERR
  32.     #define ERR(sss)
  33. #endif
  34.  
  35. #define HEAPSIZE        (64 * 1024)    /*V70のときだけ有効*/
  36. #define STACKSIZE        (64 * 1024)        /*V70のときだけ有効*/
  37. /*  メモリ管理領域  */
  38. typedef    struct {
  39.         short    id ;
  40.         long    size ;
  41.     }
  42.         MMA ;
  43.  
  44. static    char    HUGE    *allocend = NULL ;
  45. static    char    HUGE    *allocbuf = NULL ;
  46. static    char    HUGE    *nextbuf ;
  47. static    short    allocids[2] = { ALLOC_DATA_ID, ALLOC_TEMP_ID } ;
  48.  
  49. static    void    allocerror( char* );
  50.  
  51. #ifdef ONDEMANDMALLOC
  52. #define ARRAYSIZE 1024
  53. #define MAXMARK 1024
  54.  
  55. #define BUFFERLIMIT (1024)
  56. #define BUFFERSIZE    (1024*1024)
  57. /*#define BUFFERCHECK    1024*/
  58. #ifndef BUFFERCHECK
  59.     #define BUFFERCHECK 0
  60. #endif
  61.  
  62. typedef struct _MMAarray{
  63.     void *mma[ARRAYSIZE];
  64. #if BUFFERCHECK
  65.     int length[ARRAYSIZE];
  66. #endif
  67.     struct _MMAarray *next;
  68. } MMAarray;
  69.  
  70. typedef struct _MMAbuf {
  71.     char buffer[BUFFERSIZE];
  72.     struct _MMAbuf *next;
  73. } MMAbuf;
  74.  
  75. typedef struct {
  76.     MMAarray *array;
  77.     int index;
  78.  
  79.     MMAbuf *buf;
  80.     int bufremain;
  81.     void *bufpointer;
  82.  
  83.     int totalalloc;
  84. } MMAmark;
  85.  
  86. static MMAarray *top, *cur;
  87. static int curindex;
  88.  
  89. static MMAbuf *buftop, *bufcur;
  90. static void *bufpointer;
  91. static int bufremain;
  92.  
  93. static MMAmark markdata[MAXMARK];
  94. static int currentmark;
  95. static long totalalloc;
  96.  
  97. #if BUFFERCHECK
  98. static void setMagic1(unsigned char *p)
  99. {
  100.     int i;
  101.     for (i = 0; i < BUFFERCHECK; i++) {
  102.         *p++ = (i % 256);
  103.     }
  104. }
  105. static void setMagic2(unsigned char *p)
  106. {
  107.     int i;
  108.     for (i = 0; i < BUFFERCHECK; i++) {
  109.         *p++ = ((BUFFERCHECK-i) % 256);
  110.     }
  111. }
  112. static void checkMagic1(unsigned char *p)
  113. {
  114.     int i;
  115.     for (i = 0; i < BUFFERCHECK; i++) {
  116.         if (*p++ != (i%256)) {
  117.             ERR(fputc('1', fp));
  118.             return;
  119.         }
  120.     }
  121.     ERR(fputc('P', fp));
  122. }
  123. static void checkMagic2(unsigned char *p)
  124. {
  125.     int i;
  126.     for (i = 0; i < BUFFERCHECK; i++) {
  127.         if (*p++ != ((BUFFERCHECK-i)%256)) {
  128.             ERR(fputc('2', fp));
  129.             return;
  130.         }
  131.     }
  132.     ERR(fputc('N', fp));
  133. }
  134. #endif
  135.  
  136. void    meminit( long memsize )
  137. {
  138.     top = malloc(sizeof(MMAarray));
  139.     if (top == NULL) {
  140.         allocerror("メモリ初期化に失敗しました。");
  141.     }
  142.     cur = top;
  143.     cur->next = NULL;
  144.     curindex = 0;
  145.  
  146.     buftop = malloc(sizeof(MMAbuf));
  147.     if (buftop == NULL) {
  148.         allocerror("メモリ初期化に失敗しました。");
  149.     }
  150.     bufcur = buftop;
  151.     bufcur->next = NULL;
  152.     bufpointer = buftop->buffer;
  153.     bufremain = BUFFERSIZE;
  154.  
  155.     currentmark = 0;
  156.     totalalloc = 0;
  157. }
  158.  
  159. /*    領域の確保    */
  160. void    *memalloc( size )
  161. int        size ;
  162. {
  163.     void HUGE    *h ;
  164.  
  165.     assert( top != NULL );
  166.     assert( size >= 0 );
  167.     assert( size > 0);
  168.     assert(( size % 2 ) == 0 );
  169.  
  170.     size = ((size+3)/4) * 4;
  171.  
  172.     if (size <= BUFFERLIMIT) {
  173.         if (bufremain <= size) {
  174.             bufcur->next = malloc(sizeof(MMAbuf));
  175.             if (bufcur->next == NULL) {
  176.                 allocerror( "データ領域が足りません(malloc)。" );
  177.             }
  178.             bufcur = bufcur->next;
  179.             bufcur->next = NULL;
  180.             bufpointer = bufcur->buffer;
  181.             bufremain = BUFFERSIZE;
  182.         }
  183.         h = bufpointer;
  184.         bufremain -= size;
  185.         bufpointer = ((char*)bufpointer) + size;
  186.     } else {
  187. ERR(fprintf(fp, "malloc %08x:%4d (%6d) : ", cur, curindex, size));
  188.         cur->mma[curindex] = malloc(size + BUFFERCHECK*2);
  189.         if (cur->mma[curindex] == NULL) {
  190.             allocerror( "データ領域が足りません(malloc)。" );
  191.         }
  192.         h = (char*)cur->mma[curindex] + BUFFERCHECK;
  193. #if BUFFERCHECK
  194.         cur->length[curindex] = size;
  195.         setMagic1(cur->mma[curindex]);
  196.         setMagic2((char*)cur->mma[curindex] + BUFFERCHECK + size);
  197. #endif
  198. ERR(fprintf(fp, "%08x\n", h));
  199.         if (++curindex == ARRAYSIZE) {
  200.             cur->next = malloc(sizeof(MMAarray));
  201.             if (cur->next == NULL) {
  202.                 allocerror("メモリ再確保に失敗しました。");
  203.             }
  204.             cur = cur->next;
  205.             cur->next = NULL;
  206.             curindex = 0;
  207.         }
  208.     }
  209.     totalalloc += size;
  210.     return h;
  211. }
  212.  
  213. /*    配列の確保  */
  214. void    *memaryalloc( count, size )
  215. int        count, size ;
  216. {
  217.     MMA    HUGE    *h ;
  218.     long tsize;
  219.  
  220.     assert( top != NULL );
  221.     assert( size >= 0 );
  222.     assert( size > 0 && ( size % 2 ) == 0 );
  223.     size = ((size+3)/4) * 4;
  224.  
  225.     tsize = (long)size * (long)count;
  226.     if (tsize <= BUFFERLIMIT) {
  227.         if (bufremain <= tsize) {
  228.             bufcur->next = malloc(sizeof(MMAbuf));
  229.             if (bufcur->next == NULL) {
  230.                 allocerror( "データ領域が足りません(malloc)。" );
  231.             }
  232.             bufcur = bufcur->next;
  233.             bufcur->next = NULL;
  234.             bufpointer = bufcur->buffer;
  235.             bufremain = BUFFERSIZE;
  236.         }
  237.         h = bufpointer;
  238.         bufremain -= tsize;
  239.         bufpointer = ((char*)bufpointer) + tsize;
  240.     } else {
  241. ERR(fprintf(fp, "maryoc %08x:%4d (%6d) : ", cur, curindex, size*count));
  242.         cur->mma[curindex] = malloc((long)size * (long)count + BUFFERCHECK*2);
  243.         if (cur->mma[curindex] == NULL) {
  244.             allocerror( "データ領域が足りません(malloc)。" );
  245.         }
  246.         h = (char*)cur->mma[curindex] + BUFFERCHECK;
  247. #if BUFFERCHECK
  248.         cur->length[curindex] = (long)size * (long)count;
  249.         setMagic1(cur->mma[curindex]);
  250.         setMagic2((char*)cur->mma[curindex] + BUFFERCHECK + cur->length[curindex]);
  251. #endif
  252. ERR(fprintf(fp, "%08x\n", h));
  253.         if (++curindex == ARRAYSIZE) {
  254.             cur->next = malloc(sizeof(MMAarray));
  255.             if (cur->next == NULL) {
  256.                 allocerror("メモリ再確保に失敗しました。");
  257.             }
  258.             cur = cur->next;
  259.             cur->next = NULL;
  260.             curindex = 0;
  261.         }
  262.     }
  263.     totalalloc += (long)size * (long)count;
  264.     return h;
  265. }
  266.  
  267. /*    マーク    */
  268. char    *memmark()
  269. {
  270.     markdata[currentmark].array = cur;
  271.     markdata[currentmark].index = curindex;
  272.  
  273.     markdata[currentmark].buf = bufcur;
  274.     markdata[currentmark].bufpointer = bufpointer;
  275.     markdata[currentmark].bufremain = bufremain;
  276.  
  277.     markdata[currentmark].totalalloc = totalalloc;
  278. ERR(fprintf(fp, "mark    %08x\n", (char FAR*)&markdata[currentmark+1]));
  279.     return( (char FAR*)&markdata[currentmark++] );
  280. }
  281.  
  282. /*    領域の開放    */
  283. void    memrelease( markp )
  284. char    *markp ;
  285. {
  286.     int i, j;
  287.     MMAarray *p, *q;
  288.     MMAmark *mp = (MMAmark*)markp;
  289.     assert( markdata <= mp && mp <= markdata + MAXMARK );
  290. ERR(fprintf(fp, "release %08x\n", markp));
  291.     if (mp->array == cur) {
  292. ERR(fprintf(fp, "loop %d to %d\n", mp->index, curindex));
  293.         for (i = mp->index; i < curindex; ++i) {
  294. ERR(fprintf(fp, "free   %08x:%4d          : %08x", cur, i, cur->mma[i]));
  295. #if BUFFERCHECK
  296.             checkMagic1(cur->mma[i]);
  297.             checkMagic2((char*)cur->mma[i] + BUFFERCHECK + cur->length[i]);
  298. #endif
  299.             free(cur->mma[i]);
  300. ERR(fprintf(fp, " ok.\n"));
  301.         }
  302.     } else {
  303.         p = mp->array;
  304. ERR(fprintf(fp, "loop %d to %d\n", mp->index, ARRAYSIZE));
  305.         for (i = mp->index; i < ARRAYSIZE; ++i) {
  306. ERR(fprintf(fp, "free   %08x:%4d          : %08x", p, i, p->mma[i]));
  307. #if BUFFERCHECK
  308.             checkMagic1(p->mma[i]);
  309.             checkMagic2((char*)p->mma[i] + BUFFERCHECK + p->length[i]);
  310. #endif
  311.             free(p->mma[i]);
  312. ERR(fprintf(fp, " ok.\n"));
  313.         }
  314.         for (p = p->next; p != NULL && p != cur;p = q) {
  315. ERR(fprintf(fp, "loop %d to %d\n", 0, ARRAYSIZE));
  316.             for (i = 0; i < ARRAYSIZE; ++i) {
  317. ERR(fprintf(fp, "free   %08x:%4d          : %08x", p, i, p->mma[i]));
  318. #if BUFFERCHECK
  319.             checkMagic1(p->mma[i]);
  320.             checkMagic2((char*)p->mma[i] + BUFFERCHECK + p->length[i]);
  321. #endif
  322.                 free(p->mma[i]);
  323. ERR(fprintf(fp, " ok.\n"));
  324.             }
  325.             q = p->next;
  326.             free(p);
  327.         }
  328.         if (p == cur) {
  329. ERR(fprintf(fp, "loop %d to %d\n", 0, curindex));
  330.             for (i = 0; i < curindex; ++i) {
  331. ERR(fprintf(fp, "free   %08x:%4d          : %08x", p, i, p->mma[i]));
  332. #if BUFFERCHECK
  333.             checkMagic1(p->mma[i]);
  334.             checkMagic2((char*)p->mma[i] + BUFFERCHECK + p->length[i]);
  335. #endif
  336.                 free(p->mma[i]);
  337. ERR(fprintf(fp, " ok.\n"));
  338.             }
  339.             free(p);
  340.         }
  341.     }
  342.     cur = mp->array;
  343.     cur->next = NULL;
  344.     curindex = mp->index;
  345.  
  346.     bufpointer = mp->bufpointer;
  347.     bufremain = mp->bufremain;
  348.     bufcur = mp->buf;
  349.     if (bufcur->next != NULL) {
  350.         MMAbuf *pbuf, *pnext = NULL;
  351.         for (pbuf = bufcur->next; pbuf != NULL;pbuf = pnext) {
  352. ERR(fprintf(fp, "free %x\n", pbuf));
  353.             pnext = pbuf->next;
  354.             free(pbuf);
  355.         }
  356.         bufcur->next = NULL;
  357.     }
  358.  
  359.     totalalloc = mp->totalalloc;
  360.     currentmark = mp - markdata;
  361. }
  362.  
  363. /*    使用領域サイズを返す  */
  364. long    memsize()
  365. {
  366.     return totalalloc;
  367. }
  368.  
  369. long memgetsize(void)
  370. {
  371.     return 0;
  372. }
  373. #else
  374. /*
  375.  *        データバッファの処理関数
  376.  */
  377.  
  378. /*    データバッファの初期化    */
  379. void    meminit( memsize )
  380. long    memsize ;
  381. {
  382.     long    n ;
  383.     char    *errormsg = "データ領域が確保できません。" ;
  384.  
  385.     if (memsize < 0) {
  386. #if defined(X68000)
  387.     #ifdef V70
  388.         n = SBRK(0x10000000);
  389.         SBRK(n - 0x81000000 - STACKSIZE);
  390.         n = (int)MALLOC( 0x1000000 ) - 0x81000000 - HEAPSIZE;
  391.     #else
  392.         n = (int)MALLOC( 0x1000000 ) - 0x81000000 ;
  393.     #endif
  394.         n -= -memsize;
  395.         allocbuf = (char*)MALLOC( n );
  396.         assert( 0 < allocbuf && allocbuf < 0x1000000 );
  397. #elif defined(DJ) || defined(UNIX) || defined(__WIN32__)
  398.         n = 16 * 1024 * 1024;
  399.         allocbuf = malloc(n);
  400. /*        assert( 0 < allocbuf && allocbuf < 0x1000000 );*/
  401. #elif defined(MSC)
  402.         n = 400L * 1024L;
  403.         do {
  404.             n -= 1024L * 10L;
  405.             allocbuf = halloc(n, 1);
  406.         } while (allocbuf == NULL &&  n > 0);
  407.         hfree(allocbuf);
  408.         n -= -memsize;
  409.         allocbuf = halloc(n, 1);
  410.         assert( allocbuf != NULL);
  411. /*        assert( 0 < allocbuf && allocbuf < 0x1000000L );*/
  412. #elif defined(__BORLANDC__)
  413.         n = 400L * 1024L;
  414.         do {
  415.             n -= 1024L * 10L;
  416.             allocbuf = farmalloc(n);
  417.         } while (allocbuf == NULL &&  n > 0);
  418.         farfree(allocbuf);
  419.         n -= -memsize;
  420.         allocbuf = farmalloc(n);
  421.         assert( allocbuf != NULL);
  422. /*        assert( 0 < allocbuf && allocbuf < 0x1000000L );*/
  423. #endif
  424.     }
  425.     else if ( memsize == 0 )
  426.     {
  427.         /*    とれるだけとる    */
  428. #if defined(X68000)
  429.     #ifdef V70
  430.         n = SBRK(0x10000000);
  431.         SBRK(n - 0x81000000 - STACKSIZE);
  432.         n = (int)MALLOC( 0x1000000 ) - 0x81000000 - HEAPSIZE;
  433.     #else
  434.         n = (int)MALLOC( 0x1000000 ) - 0x81000000 ;
  435.     #endif
  436.         allocbuf = MALLOC( n );
  437.         assert( 0 < allocbuf && allocbuf < 0x1000000 );
  438. #elif defined(DJ) || defined(UNIX) || defined (__WIN32__)
  439.         n = 16 * 1024 * 1024;
  440.         allocbuf = malloc(n);
  441.         assert( 0 < allocbuf && allocbuf < 0x1000000 );
  442. #elif defined(MSC)
  443.         n = 400L * 1024L;
  444.         do {
  445.             n -= 1024L * 10L;
  446.             allocbuf = halloc(n, 1);
  447.         } while (allocbuf == NULL &&  n > 0);
  448.         assert( allocbuf != NULL);
  449. #elif defined(__BORLANDC__)
  450.         n = 400L * 1024L;
  451.         do {
  452.             n -= 1024L * 10L;
  453.             allocbuf = farmalloc(n);
  454.         } while (allocbuf == NULL &&  n > 0);
  455.         assert( allocbuf != NULL);
  456. #endif
  457.     }
  458.     else
  459.     {
  460.         n = memsize ;
  461. #if defined(X68000)
  462.         allocbuf =  (char*)MALLOC( n );
  463.         if ( allocbuf <= 0 || 0x1000000 <= allocbuf )
  464.             allocerror( errormsg );
  465. #elif defined(DJ) || defined(UNIX) || defined(__WIN32__)
  466.         allocbuf = malloc( n );
  467.         if ( allocbuf == NULL )
  468.             allocerror( errormsg );
  469. #elif defined(MSC)
  470.         allocbuf = halloc( n, 1 );
  471.         if ( allocbuf == NULL )
  472.             allocerror( errormsg );
  473. #elif defined(__BORLANDC__)
  474.         allocbuf = farmalloc( n );
  475.         if ( allocbuf == NULL )
  476.             allocerror( errormsg );
  477. #endif
  478.     }
  479.     allocend = allocbuf + n ;
  480.     nextbuf = allocbuf ;
  481. /*
  482.     printf("allocbuf=%04x:%04x\n", FP_SEG(allocbuf), FP_OFF(allocbuf));
  483.     printf("allocend=%04x:%04x\n", FP_SEG(allocend), FP_OFF(allocend));
  484.     printf("nextbuf =%04x:%04x\n", FP_SEG(nextbuf), FP_OFF(nextbuf));
  485. */
  486. }
  487.  
  488. long memgetsize(void)
  489. {
  490.     return (unsigned long)allocend - (unsigned long)nextbuf;
  491. }
  492.  
  493. /*    領域の確保    */
  494. void    *memalloc( size )
  495. int        size ;
  496. {
  497.     MMA    HUGE    *h ;
  498.  
  499.     assert( allocbuf != NULL );
  500.     assert( size > 0 && ( size % 2 ) == 0 );
  501.  
  502. /*    printf("memalloc:%d\n", size);*/
  503.  
  504.     /*    バッファの確保    */
  505.     h = (MMA*)nextbuf ;
  506.  
  507. /*    printf("nextbuf: %04X:%04X -> ", FP_SEG(nextbuf), FP_OFF(nextbuf));*/
  508.  
  509.     nomalize_pointer( h );
  510.  
  511.     nextbuf += size + sizeof( MMA ) ;
  512. /*    printf("%04X:%04X\n", FP_SEG(nextbuf), FP_OFF(nextbuf));*/
  513.     if ( nextbuf > allocend )
  514.     {
  515.         allocerror( "データ領域が足りません(malloc)。" );
  516.     }
  517.     h->id = ALLOC_DATA_ID ;
  518.     h->size = (long)size ;
  519.  
  520.     return( (void*)( h + 1 ) );
  521. }
  522.  
  523. /*    配列の確保  */
  524. void    *memaryalloc( count, size )
  525. int        count, size ;
  526. {
  527.     MMA        *h ;
  528.  
  529.     assert( allocbuf != NULL );
  530.     assert( size > 0 && ( size % 2 ) == 0 );
  531.  
  532.     /*    バッファの確保    */
  533.     h = (MMA*)nextbuf ;
  534.     nomalize_pointer( h );
  535.     h->id = ALLOC_DATA_ID ;
  536.     h->size = (long)size * (long)count ;
  537.  
  538.     nextbuf += h->size + (long)sizeof( MMA ) ;
  539.     if ( nextbuf > allocend )
  540.         allocerror( "データ領域が足りません(arraymalloc)。" );
  541.  
  542.     return( (void*)( h + 1 ) );
  543. }
  544.  
  545. /*    マーク    */
  546. char    *memmark()
  547. {
  548.     return( (char FAR*)nextbuf );
  549. }
  550.  
  551. /*    領域の開放    */
  552. void    memrelease( p )
  553. char    *p ;
  554. {
  555.     assert( allocbuf <= (char HUGE*)p && (char HUGE*)p <= nextbuf );
  556.     nextbuf = (char HUGE*)p ;
  557. }
  558.  
  559. /*    使用領域サイズを返す  */
  560. long    memsize()
  561. {
  562.     return( (unsigned long)( nextbuf - allocbuf ) );
  563. }
  564.  
  565. /*  使用可能サイズを返す  */
  566. long    memallsize()
  567. {
  568.     return( (unsigned long)( allocend - nextbuf ) );
  569. }
  570.  
  571. #endif
  572. /*
  573.  *        ワーク領域(ヒープ)の処理関数
  574.  */
  575.  
  576. /*    ワークバッファの確保  */
  577. void    *tempalloc( size )
  578. int        size ;
  579. {
  580.     MMA        *h ;
  581.  
  582.     assert( size > 0 );
  583.     assert( size < 32000 );
  584.     assert( ( size % 2 ) == 0 );
  585.  
  586.     h = (MMA*)malloc( size + sizeof( MMA ) );
  587.     if ( h == NULL )
  588.         allocerror( "ヒープ領域が足りません。" );
  589.  
  590.     h->id = ALLOC_TEMP_ID ;
  591.     h->size = size ;
  592.  
  593.     return( (void*)( h + 1 ) );
  594. }
  595.  
  596. /*    ワークバッファの開放  */
  597. void    tempfree( p )
  598. void    *p ;
  599. {
  600.     MMA        *h ;
  601.  
  602.     assert( memcheck( p, p, ALLOC_TYPE_TEMP ) );
  603.     h = (MMA*)p - 1 ;
  604.  
  605.     free( (char*)h );
  606. }
  607.  
  608. /*    ワークバッファの再確保    */
  609. void    *temprealloc( p, size )
  610. void    *p ;
  611. int        size ;
  612. {
  613.     void    *pp ;
  614.  
  615.     pp = tempalloc( size );
  616.     memcpy( pp, p, size );
  617.     tempfree( p );
  618.  
  619.     return( pp );
  620. }
  621.  
  622.  
  623. /*
  624.  *        その他の関数
  625.  */
  626.  
  627. /*    エラーメッセージ出力  */
  628. static    void    allocerror( msg )
  629. char    *msg ;
  630. {
  631. #ifdef MESSAGE
  632.     extern int printwarning(const char *format, ...);
  633.     printwarning( "%s", msg);
  634. #endif
  635.     fprintf( stderr, "\n\7%s\n\n", msg );
  636.     exit( 1 );
  637. }
  638.  
  639. /*    領域のチェック    */
  640. int        memcheck( top, refer, flag )
  641. void    *top ;
  642. void    *refer ;
  643. int        flag ;
  644. {
  645.     long    size ;
  646.     MMA        HUGE    *h ;
  647.  
  648.     h = (MMA*)top ;
  649.     h -- ;
  650.     if ( h->id != allocids[ flag ] )
  651.     {
  652.         fprintf( stderr,
  653.             "\n\7メモリ管理領域が破壊されました。!!\n\n" );
  654.         return( FALSE );
  655.     }
  656.     size = (char HUGE *)refer - (char HUGE *)top ;
  657.     if ( size < 0L || h->size <= size )
  658.     {
  659.         fprintf( stderr,
  660.             "\n\7不正なアドレスを参照しようとしています。!!\n\n" );
  661.         return( FALSE );
  662.     }
  663.     return( TRUE );
  664. }
  665.