亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? memio.c

?? internich公司實(shí)現(xiàn)的一個非常非常小的OS
?? C
字號:
/* * FILENAME: memio.c * * Copyright 1998- 2004 By InterNiche Technologies Inc. All rights reserved * * memio.c calloc() & free() workalikes (calloc1() and mem_free())  * designed for embedded systems. 8/21/98 - first use, on AMD Net186.  * * MODULE: NTF * * ROUTINES: calloc1(), mem_free(), mheap_init(),  * ROUTINES: mh_stats(), mh_startfree(), * PORTABLE: yes */#include "license.h"#include "ipport.h"#include "in_utils.h"#include "memwrap.h"extern unsigned memtrapsize;     /* alloc size to dtrap on */struct mem_block{#ifdef NPDEBUG   int         pattern;       /* pattern for testing overwrites */#endif   /* NPDEBUG */   struct mem_block *   next; /* pointer to next block */   unsigned    size;          /* size of block (excluding this header) */};/* define a pattern for putting in every mem block - this is used to  * check for overwrites. This declaration assumes ALIGN_TYPE is the  * same as  */#if (ALIGN_TYPE == 4)#define  MEM_PATTERN    0x6D656D70  /* ascii for MEMP */#elif (ALIGN_TYPE == 2)#define  MEM_PATTERN    0x6D65      /* ascii for ME */#else#define  MEM_PATTERN    0x6D        /* ascii M */#endif#define MEMBLOCKSIZE ((sizeof(struct mem_block) & (ALIGN_TYPE - 1)) ? \   ((sizeof(struct mem_block) + ALIGN_TYPE) & ~(ALIGN_TYPE - 1)) : \   (sizeof(struct mem_block)))struct mem_block *   mh_free;struct mem_block *   mheap_base;long     mh_startfree;  /* heap size (in bytes) at init time */long     mh_totfree;    /* current free heap size */long     mh_minfree;    /* minimum free heap size seen */long     mh_failed;     /* number of times alloc failed *//* FUNCTION: mheap_init() * * Called at system init time to set up heap for use. MUST be called * before any calls to calloc1(). Takes a single contiguous memory space * and sets it up to be used by calloc1() anbd mem_free(). * * PARAM1: char * base - address for start of heap area in memory * PARAM2: long size  - size of heap area at address. * * RETURNS: void */voidmheap_init(char * base, long size){   /* make sure the heap is aligned */   if ((long)base & (ALIGN_TYPE-1))   {      base = (char*)(((long)base + (ALIGN_TYPE-1)) & ~(ALIGN_TYPE-1));      size -= (ALIGN_TYPE-1);   }   mheap_base = (struct mem_block *)base;   mh_free = (struct mem_block *)base;   /* trim heap to multiple of ALIGN_TYPE */   size &= ~(ALIGN_TYPE-1);   /* start with no free space (we will add to this) */   mh_totfree = 0;#ifdef SEG16_16   if (size > 0x0000FFF0)  /* segment limits force multiple blocks */   {      unsigned seg, offset;      struct mem_block *   tmp;      tmp = mh_free;      seg = _FP_SEG(mh_free);      offset = _FP_OFF(mh_free);      while (size >= 0)      {         tmp->size = ((size>0xFFF0)?0xFFF0:(unsigned)size) - MEMBLOCKSIZE;         mh_totfree += tmp->size;         size -= 0xFFF0;         seg += 0x0FFF;#ifdef NPDEBUG         tmp->pattern = MEM_PATTERN;    /* set pattern for testing overwrites */#endif   /* NPDEBUG */         tmp->next = _MK_FP(seg, offset);         if (size >= 0) /* need more entrys? */            tmp = tmp->next;  /* prepare for next loop */         else            tmp->next = NULL; /* terminate list */      }    }   else  /* make one big free block */#endif   /* SEG16_16 */   {      mh_free->size = (unsigned)size - MEMBLOCKSIZE;      mh_totfree += mh_free->size;      mh_free->next = NULL;#ifdef NPDEBUG      mh_free->pattern = MEM_PATTERN;     /* set pattern for testing overwrites */#endif   /* NPDEBUG */   }   /* set starting and minimum free space from the just-initialized total */   mh_startfree = mh_minfree = mh_totfree;}/* FUNCTION: calloc1() * * Similar to standard calloc(), except it only takes 1 size arg. * * PARAM1: unsigned size * * RETURNS: pointer to memif OK, else NULL */char *   calloc1(unsigned size){   unsigned lostsize;      /* size of data block plus struct */   struct mem_block *   bp;   struct mem_block *   newb;   struct mem_block *   lastb;#if (ALIGN_TYPE > 1)   /* increase requested size enough to ensure future alignment */   if ((long)size & (ALIGN_TYPE-1))   {      size = (size + ALIGN_TYPE) & ~(ALIGN_TYPE-1);   }#endif   lostsize = size + MEMBLOCKSIZE;  /* size we will take from heap */   ENTER_CRIT_SECTION(mh_free);   bp = mh_free;                    /* init vars for list search */   lastb = NULL;   while (bp)   {#ifdef NPDEBUG      if (bp->pattern != MEM_PATTERN)  /* test for corruption */      {         dtrap();         EXIT_CRIT_SECTION(mh_free);         return NULL;   /* probably should be panic */      }#endif   /* NPDEBUG */      if (bp->size >= size)   /* take first-fit free block */      {         /* Decide if the block is big enough to be worth dividing */         if (bp->size > (size + (MEMBLOCKSIZE * 2)))         {            /* Divide block and return front part to caller. First             * make a new block after the portion we will return             */            newb = (struct mem_block *)((char*)(bp) + lostsize);            newb->size = bp->size - lostsize;            newb->next = bp->next;#ifdef NPDEBUG            newb->pattern = MEM_PATTERN;   /* set test pattern */#endif   /* NPDEBUG */            /* modify bp to reflect smaller size we will return */            bp->next = newb;            bp->size = size;         }         else  /* not worth fragmenting block, return whole thing */         {            lostsize = bp->size + MEMBLOCKSIZE;       /* adjust lostsize */         }         if (lastb)   /* unlink block from queue */            lastb->next = bp->next;         else            mh_free = bp->next;         /* keep statistics */         mh_totfree -= lostsize;         if (mh_totfree < mh_minfree)            mh_minfree = mh_totfree;         bp->next = mheap_base;     /* tag next ptr with illegal value */         EXIT_CRIT_SECTION(mh_free);         return((char*)(bp) + MEMBLOCKSIZE);      }      lastb = bp;      bp = bp->next;   }   EXIT_CRIT_SECTION(mh_free);   mh_failed++;   /* count out of memory conditions */   return NULL;   /* failure return - no memory */}/* FUNCTION: mem_free() *  * Find block which contains buf and insert it in free  * list. Maintains list in order, low to high memory.  * * PARAM1: char HUGE * buf - buffer to add to free list. * * RETURNS: void */voidmem_free(char HUGE * buf){   struct mem_block  HUGE *   freep;   struct mem_block  HUGE *   tmp;   struct mem_block  HUGE *   last;   int   merged   =  0; /* indicates freep not merged into free list */   /* find pointer to prepended mem_block struct */   freep = (struct mem_block*)(buf - MEMBLOCKSIZE);   if (freep->next != mheap_base)      /* sanity check next ptr for tag */      panic("mem_free");   mh_totfree += ((unsigned long)freep->size + MEMBLOCKSIZE);   last = NULL;   for (tmp = mh_free; tmp; tmp = tmp->next)   {#ifdef NPDEBUG      if (tmp->pattern != MEM_PATTERN) /* test for corruption */      {         dtrap();    /* memory is corrupt, tell programmer! */         return;     /* probably should be panic */      }#endif   /* NPDEBUG */      if (freep < tmp)  /* found slot to insert freep */      {         /* see if we can merge with next block */         if (((char*)freep + freep->size + MEMBLOCKSIZE) == (char*)tmp)         {            freep->next = tmp->next;            freep->size += (tmp->size + MEMBLOCKSIZE);            if (last)               last->next = freep;            else               mh_free = freep;            merged++;         }#ifdef MEMIO_DEBUG         /* this and the test below check for conditions where the end of a block          * being freed is just a few bytes away from an adjacent block. This          * usually means the block size of off by the size of the mgt header.          * These tests chould be enabled and run for a while after any port of          * or surgery to this file.          */         else         if (((char HUGE *)freep + freep->size + MEMBLOCKSIZE) > (char HUGE *)(tmp - 3))         {            dprintf("memfree: this-end: %p, next: %p\n",               ((char*)freep + freep->size + MEMBLOCKSIZE), tmp );            dtrap();         }#endif         /* ...and see if we can merge with previous block */         if (last && (((char*)last + last->size + MEMBLOCKSIZE) == (char*)freep))         {            last->size += (freep->size + MEMBLOCKSIZE);            if (merged) /* if already merged, preserve next ptr */            {               last->next = freep->next;            }            merged++;         }#ifdef MEMIO_DEBUG         else         if (last && (((char HUGE *)last + last->size + MEMBLOCKSIZE) > (char HUGE *)(freep-3)))         {            dprintf("memfree: last-end: %p, this: %p\n",               ((char*)last + last->size + MEMBLOCKSIZE), freep );            dtrap();         }#endif                     /* if didn't merge with either adjacent block, insert into list */         if (!merged)            {            if (last)            {               freep->next = last->next;               last->next = freep;            }            else     /* no last, put at head of list */            {               freep->next = mh_free;               mh_free = freep;            }            mh_totfree -= MEMBLOCKSIZE;   /* we didn't get a header back */         }         return;      }      last = tmp;       /* set "last" pointer for next loop */   }   /* got to end of list without finding slot for freep; add to end */   if (last)   {      /* See if we can merge it with last block */      if (((char*)last + last->size + MEMBLOCKSIZE) == (char*)freep)      {         last->size += (freep->size + MEMBLOCKSIZE);      }      else      {         freep->next = last->next;         last->next = freep;      }   }   else     /* there was no free list */   {      mh_free = freep;      freep->next = NULL;   }}#ifdef HEAP_STATS/* FUNCTION: mh_stats() * * The console routine to printf the heap stats. * * PARAM1: void * pio - output device (NULL for console) * * RETURNS: 0 */intmh_stats(void * pio){   int   i  =  0;   unsigned long freeheap = 0;   struct mem_block *   tmp;   ns_printf(pio, "free list:\n");   for (tmp = mh_free; tmp; tmp = tmp->next)   {      freeheap += tmp->size;      ns_printf(pio, "%d: at %p, 0x%x bytes\n", i, tmp, tmp->size);      if(tmp->next == mheap_base)   /* was tmp alloced during ns_printf? */      {         ns_printf(pio, "list collision, terminating dump\n");           break;      }      i++;   }   ns_printf(pio, "heap; start: %lu,  min: %lu,  current: %lu;  actual: %lu ",      mh_startfree, mh_minfree, mh_totfree, freeheap);   ns_printf(pio, "alloc failed: %lu\n", mh_failed);#ifdef MEM_WRAPPERS   wrap_stats(pio);     /* list optional wrapper stats */#endif   return 0;}#else/* if HEAP_STATS is not used, provide a dummy function */intmh_stats(void * pio){   ns_printf(pio, "no heap stats on this build\n");   return 0;}#endif   /* HEAP_STATS */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
免费成人在线播放| 国产午夜精品福利| 久久99国内精品| 国产精品国产自产拍在线| 欧美久久久久久久久中文字幕| 国产成人99久久亚洲综合精品| 亚洲一区在线播放| 国产精品视频在线看| 91精品国产综合久久婷婷香蕉 | 丁香激情综合五月| 午夜精品在线看| 国产精品高潮呻吟| 欧美sm极限捆绑bd| 欧美日精品一区视频| 99re66热这里只有精品3直播| 久久99精品国产麻豆婷婷洗澡| 有码一区二区三区| 国产精品久久久久久久久动漫 | 7777精品伊人久久久大香线蕉 | 美女视频黄久久| 亚洲黄色尤物视频| 国产精品免费久久| 2023国产精品自拍| 制服视频三区第一页精品| 91免费小视频| 粉嫩aⅴ一区二区三区四区| 久久99国产精品久久99果冻传媒| 性感美女久久精品| 一区二区成人在线视频| 亚洲丝袜美腿综合| 亚洲欧洲另类国产综合| 国产欧美一区二区精品仙草咪| 精品国产一区二区在线观看| 日韩免费视频线观看| 欧美一级理论性理论a| 欧美日韩国产精品成人| 欧美日韩国产乱码电影| 欧美日韩aaaaa| 欧美伦理电影网| 欧美精品vⅰdeose4hd| 欧美喷潮久久久xxxxx| 欧美区一区二区三区| 欧美一区二区视频网站| 日韩欧美亚洲国产另类 | 综合网在线视频| 国产精品久久久久aaaa樱花 | 日韩一级免费观看| 日韩欧美一二三四区| 亚洲精品一区二区精华| 久久蜜桃av一区二区天堂 | 一本大道久久精品懂色aⅴ| 91在线视频免费观看| 91首页免费视频| 成人免费va视频| 在线中文字幕一区| 911精品产国品一二三产区| 日韩欧美国产麻豆| 久久嫩草精品久久久精品| 中文字幕不卡三区| 樱花影视一区二区| 人禽交欧美网站| 国产精品123区| 色诱视频网站一区| 在线不卡的av| 久久久久久**毛片大全| 日韩一级欧美一级| 欧美理论电影在线| 久久婷婷色综合| 国产精品嫩草影院com| 亚洲日本丝袜连裤袜办公室| 日韩高清国产一区在线| 国产综合色产在线精品| 色综合天天综合网国产成人综合天 | 日本va欧美va精品发布| 国产精品一品视频| 色欧美88888久久久久久影院| 欧美精品在线观看播放| 国产日韩欧美一区二区三区综合| 亚洲欧美一区二区视频| 视频一区免费在线观看| 国产一区二区在线观看免费 | 久久久99精品久久| 一区二区三区日本| 久久激情五月激情| 一本高清dvd不卡在线观看| 91精品国产色综合久久不卡电影| 中文字幕乱码久久午夜不卡| 亚洲午夜在线电影| 国产精品18久久久久| 欧美肥胖老妇做爰| 成人欧美一区二区三区在线播放| 日韩黄色小视频| 91视频国产资源| 精品国产免费一区二区三区四区| 亚洲精品中文在线| 国产一二精品视频| 这里只有精品视频在线观看| 日韩伦理免费电影| 国产成人在线观看免费网站| 7799精品视频| 亚洲激情av在线| 福利一区在线观看| 亚洲精品在线观| 日日嗨av一区二区三区四区| 色婷婷久久一区二区三区麻豆| 久久精品人人爽人人爽| 日本大胆欧美人术艺术动态| 色婷婷综合五月| 中文文精品字幕一区二区| 美女一区二区三区在线观看| 欧美三级日韩在线| 亚洲美女视频一区| 成人一区二区三区| 久久这里只精品最新地址| 日韩高清一区二区| 欧美午夜电影网| 亚洲最新在线观看| av动漫一区二区| 国产日产欧美一区| 国产真实乱偷精品视频免| 日韩欧美成人一区| 亚洲成人免费影院| 欧美色图激情小说| 怡红院av一区二区三区| 成人av网站大全| 国产精品美女久久久久久久久久久| 韩国v欧美v亚洲v日本v| 99免费精品视频| 日韩欧美一区二区久久婷婷| 午夜精品一区二区三区三上悠亚| 在线一区二区观看| 亚洲精品福利视频网站| 色狠狠色狠狠综合| 一区二区三区在线看| 在线一区二区视频| 亚洲成人一区二区| 欧美日韩视频第一区| 亚洲电影欧美电影有声小说| 欧美日韩成人综合| 日本伊人精品一区二区三区观看方式| 91精品婷婷国产综合久久性色| 日韩国产精品久久久| 日韩午夜精品电影| 国产一区二区影院| 国产精品久久免费看| 一本一本大道香蕉久在线精品| 亚洲日本韩国一区| 欧美探花视频资源| 日韩精品电影在线观看| 精品人在线二区三区| 国产精品一区二区在线播放 | 一区二区三区欧美激情| 精品视频全国免费看| 强制捆绑调教一区二区| 欧美草草影院在线视频| 国产精品亚洲第一区在线暖暖韩国| 欧美激情中文字幕一区二区| 99国产欧美久久久精品| 一区二区三区成人| 欧美性猛交xxxx黑人交| 亚洲毛片av在线| 亚洲午夜电影在线观看| 欧美日韩三级在线| 奇米一区二区三区| 久久久久国产精品人| 成人久久久精品乱码一区二区三区| 中文字幕一区二区三中文字幕| 91尤物视频在线观看| 亚洲成a天堂v人片| 欧美大片免费久久精品三p| 高清国产一区二区| 亚洲欧美欧美一区二区三区| 欧美精品777| 风间由美中文字幕在线看视频国产欧美| 亚洲精品福利视频网站| 日韩精品在线看片z| 91小视频免费观看| 麻豆免费精品视频| 亚洲丝袜美腿综合| 日韩精品一区二区三区在线| 成人国产精品免费观看视频| 午夜伊人狠狠久久| 国产三级一区二区| 欧美日韩精品专区| www.在线欧美| 狠狠色丁香婷婷综合久久片| 亚洲精品第一国产综合野| 精品久久人人做人人爽| 日本韩国欧美国产| 国产美女精品在线| 三级久久三级久久| 国产精品久久久一本精品 | 7777女厕盗摄久久久| 亚洲精选一二三| 在线不卡中文字幕播放| 99久久精品免费观看| 韩国三级中文字幕hd久久精品| 亚洲国产日韩a在线播放性色| 国产午夜精品一区二区| 欧美一区二区三区免费观看视频 |