⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrix.c

📁 spiht的压缩解压缩c编写的
💻 C
字号:
#include "spiht.h"
#include "spihtdecode.h"

QccMatrix QccMatrixAlloc(int num_rows, int num_cols)
{
  QccMatrix matrix;
  int row;
  
  if ((num_rows <= 0) || (num_cols <= 0))
    return(NULL);

  if ((matrix = 
       (QccMatrix)malloc(sizeof(QccVector)*num_rows)) == NULL)
    {
      QccErrorAddMessage("(QccMatrixAlloc): Error allocating memory");
      return(NULL);
    }
  
  for (row = 0; row < num_rows; row++)
    if ((matrix[row] = QccVectorAlloc(num_cols)) == NULL)
      {
        QccErrorAddMessage("(QccMatrixAlloc): Error allocating memory");
        free(matrix);
        return(NULL);
      }
  
  return(matrix);
}

void QccMatrixFree(QccMatrix matrix, int num_rows)
{
  int row;
  
  if (matrix != NULL)
    {
      for (row = 0; row < num_rows; row++)
        QccVectorFree(matrix[row]);

      free(matrix);
    }
}

int QccMatrixCopy(QccMatrix matrix1, const QccMatrix matrix2,
                  int num_rows, int num_cols)
{
  int row, col;

  if ((matrix1 == NULL) || 
      (matrix2 == NULL) ||
      (num_rows <= 0) ||
      (num_cols <= 0))
    return(0);

  for (row = 0; row < num_rows; row++)
    for (col = 0; col < num_cols; col++)
      matrix1[row][col] = matrix2[row][col];

  return(0);
}

⌨️ 快捷键说明

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