MLGetIntegerList (C 函数)

MLGetIntegerList 已经被 WSGetIntegerList 所取代.

int MLGetIntegerList(MLINK link,int **a,long *n)

从由 link 指定的 MathLink 连接中获取一个整数列表,把整数存在数组 a,列表的长度存在 n 中.

更多信息

  • MLGetIntegerList() 为整数数组分配内存. 必须调用 MLDisownIntegerList() 释放该内存. 如果 MLGetIntegerList() 失败,函数的返回值表明一个错误,不要调用有 a 内容的 WLDisownIntegerList().
  • MLGetIntegerList() 返回不可变的数据.
  • MLGetIntegerList() 在错误事件中返回0,如果函数成功则返回非零值.
  • 如果 MLGetIntegerList() 失败,则使用 MLError() 检索错误代码.
  • MLGetIntegerList() 在 MathLink 的标头文件 mathlink.h 中被声明.
  • MLGetIntegerList() 等同于 MLGetInteger32List().

范例

基本范例  (1)

#include "mathlink.h"

/* read a list of integers from a link */

void f(MLINK lp)
{
    int *data;
    long length;

    if(! MLGetIntegerList(lp, &data, &length))
        {
            /* unable to read the integer list from lp */
            return;
        }

    /* ... */

    MLDisownIntegerList(lp, data, length);
}