forked from eugenechevski/CodeGeneratorSPL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile_location.c
More file actions
executable file
·34 lines (32 loc) · 1014 Bytes
/
file_location.c
File metadata and controls
executable file
·34 lines (32 loc) · 1014 Bytes
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
/* $Id: file_location.c,v 1.2 2023/11/13 05:13:47 leavens Exp $ */
#include <stdlib.h>
#include <assert.h>
#include <stddef.h>
#include "file_location.h"
#include "utilities.h"
// Requires: filename != NULL
// Return a (pointer to a) fresh file_location with the given
// information
file_location *file_location_make(const char *filename,
unsigned int line)
{
file_location *ret = (file_location *) malloc(sizeof(file_location));
if (ret == NULL) {
bail_with_error("Could not allocate space for a file_location!");
}
ret->filename = filename;
ret->line = line;
return ret;
}
// Requires: fl != NULL
// Return a (pointer to a) fresh copy of fl
file_location *file_location_copy(file_location *fl)
{
file_location *ret = (file_location *) malloc(sizeof(file_location));
if (ret == NULL) {
bail_with_error("Could not allocate space for a file_location!");
}
ret->filename = fl->filename;
ret->line = fl->line;
return ret;
}