smalloc()

smalloc()

概要

引数

実装

  168: void*
  169: smalloc(ulong size)
  170: {
  171:         void *v;
  172: 
  173:         for(;;) {
  174:                 v = poolalloc(mainmem, size+Npadlong*sizeof(ulong));
  175:                 if(v != nil)
  176:                         break;
  177:                 tsleep(&up->sleep, return0, 0, 100);
  178:         }
  179:         if(Npadlong){
  180:                 v = (ulong*)v+Npadlong;
  181:                 setmalloctag(v, getcallerpc(&size));
  182:         }
  183:         memset(v, 0, size);
  184:         return v;
  185: }
  • 確保した領域をゼロクリアし,領域の先頭アドレスを返す.