File: ppm_memory.c

package info (click to toggle)
gnuift 0.1.14%2Bds-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 5,632 kB
  • ctags: 2,973
  • sloc: cpp: 15,867; sh: 8,281; ansic: 1,812; perl: 1,007; php: 651; makefile: 483; lisp: 344
file content (34 lines) | stat: -rw-r--r-- 565 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <math.h>
#include <string.h>
#include <unistd.h>

#include "ppm.h"

/* PPM and PGM utilities */

/* David Squire 980924 */

PPM *new_ppm() {
	
	PPM *the_ppm;

	the_ppm = (PPM *)malloc(sizeof(PPM));
	the_ppm->comments = NULL;
	the_ppm->comment_length = 0;
	the_ppm->pixel = NULL;

	return(the_ppm);
}

void destroy_ppm(PPM **the_ppm) {

	if ((*the_ppm)->comments != NULL)
		free((*the_ppm)->comments);
	if ((*the_ppm)->pixel != NULL)
		free((*the_ppm)->pixel);
	free(*the_ppm);
	*the_ppm = NULL;
}