ovstr.c

来自「汇编语言编的关于ov143b.asm的小程序」· C语言 代码 · 共 64 行

C
64
字号
/*  002  20-Apr-87  ovstr.c

        Some OV specific string routines.

        Copyright (c) 1987 by Blue Sky Software.  All rights reserved.
*/

#include "ov.h"


/*****************************************************************************
                             M U S T A L L O C
 *****************************************************************************/

char * ALTCALL
mustalloc(len)         /* allocate memory or die */
int len;
{
   char *mp;

   if (mp = (char *) malloc(len))      /* try to allocate, return addr if ok */
      return(mp);

   /* Can't allocate, time to die! The following routines better not call us! */

   reset_tty();
   putstr("\r\nOverView ran out of memory!\r\n");
   exit();
}


/*****************************************************************************
                             M U S T D U P
 *****************************************************************************/

char * ALTCALL
mustdup(sp)    /* duplicate a string or die */
char *sp;
{
   char *nsp;

   nsp = mustalloc(strlen(sp)+1);
   strcpy(nsp,sp);
   return(nsp);
}


/*****************************************************************************
                           M U S T N D U P
 *****************************************************************************/

char * ALTCALL
mustndup(sp,n)         /* duplicate part of a string or die! */
char *sp;
int n;
{
   char *nsp;

   nsp = mustalloc(n+1);
   *nsp = '\0';
   strncat(nsp,sp,n);
   return(nsp);
}

⌨️ 快捷键说明

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