"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/matrix.c" between
grpn-1.5.1.tar.gz and grpn-1.5.2.tar.gz

About: grpn is a RPN calcuator for real and complex numbers (requires GTK).

matrix.c  (grpn-1.5.1):matrix.c  (grpn-1.5.2)
skipping to change at line 34 skipping to change at line 34
#include <memory.h> #include <memory.h>
#include <string.h> #include <string.h>
#include "matrix.h" #include "matrix.h"
#include "number.h" #include "number.h"
#include "error.h" #include "error.h"
#include "constant.h" #include "constant.h"
/* get the space for the data */ /* get the space for the data */
Number ** mallocData(Number **d, int rows, int cols){ Number ** mallocData(Number **d, int rows, int cols){
int i, j;
int size; int size;
Number **p; Number **p;
if(d){ if(d){
size = rows*cols*sizeof(Number *); size = rows*cols*sizeof(Number *);
if(NULL == (p=(Number **)realloc((char *)d, size))){ if(NULL == (p=(Number **)realloc((char *)d, size))){
perror("realloc"); exit(0); perror("realloc"); exit(0);
} }
} else { } else {
if(NULL == (p = (Number **)malloc(rows*cols*sizeof(Number *)))){ if(NULL == (p = (Number **)malloc(rows*cols*sizeof(Number *)))){
skipping to change at line 105 skipping to change at line 104
((a->rows*a->cols)-(oldrows*oldcols))*sizeof(Number *)); ((a->rows*a->cols)-(oldrows*oldcols))*sizeof(Number *));
} }
row--; col--; row--; col--;
ptr = a->data + (a->cols * row) + col; ptr = a->data + (a->cols * row) + col;
*ptr = setNumberNumber(newNumber(), b); *ptr = setNumberNumber(newNumber(), b);
} }
Matrix * setMatrixMatrix(Matrix *a, Matrix *b){ Matrix * setMatrixMatrix(Matrix *a, Matrix *b){
int i, j; int i, j;
Number *n1;
Number **ptr1, **ptr2; Number **ptr1, **ptr2;
if(a == NULL || b == NULL) if(a == NULL || b == NULL) {
{ fprintf(stderr, "setMatrixMatrix(NULL)\n"); exit(0); } fprintf(stderr, "setMatrixMatrix(NULL)\n"); exit(0);
}
/* initalize the stuff in p */ /* initalize the stuff in p */
a->data = mallocData(NULL, b->rows, b->cols); a->data = mallocData(NULL, b->rows, b->cols);
a->rows = b->rows; a->rows = b->rows;
a->cols = b->cols; a->cols = b->cols;
/* p[i][j] = b + a[i][j] */ /* p[i][j] = b + a[i][j] */
for(i=0; i<a->rows; i++) for(i=0; i<a->rows; i++)
for(j=0; j<a->cols; j++){ for(j=0; j<a->cols; j++){
ptr1 = b->data + (a->cols * i) + j; ptr1 = b->data + (a->cols * i) + j;
 End of changes. 3 change blocks. 
4 lines changed or deleted 3 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)