calloc.c

来自「上课老师给的8086仿真器」· C语言 代码 · 共 42 行

C
42
字号
/***********************************************************************/
/*  This file is part of the C51 Compiler package                      */
/*  Copyright KEIL ELEKTRONIK GmbH 1993                                */
/***********************************************************************/
/*                                                                     */
/*  CALLOC.C:                                                          */
/*                                                                     */
/*  To translate this file use C51 with the following invocation:      */
/*                                                                     */
/*     C51 CALLOC.C  <memory model>                                    */
/*                                                                     */
/*  To link the modified CALLOC.OBJ file to your application use the   */
/*  following L51 invocation:                                          */
/*                                                                     */
/*     L51 <your object file list>, CALLOC.OBJ <controls>              */
/*                                                                     */
/***********************************************************************/

#include <string.h>

extern void *malloc (int);

struct mem  {
  struct mem xdata *next;
  struct mem xdata *prev;
  unsigned int       len;
  unsigned char      mem[1];
};



void * calloc (unsigned int size, unsigned int len)  {
  void xdata *p;

  size *= len;
  p = malloc (size);
  if (!p) return ((void *) 0);
  memset (p, 0, size);
  return (p);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?