MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / loadcodefiledata

Function loadcodefiledata

src/debugmem.cpp:1132–1184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1130}
1131
1132static bool loadcodefiledata(struct debugcodefile *cf)
1133{
1134 TCHAR fpath[MAX_DPATH];
1135 fpath[0] = 0;
1136 if (cf->path)
1137 _tcscat(fpath, cf->path);
1138 _tcscat(fpath, cf->name);
1139 struct zfile *zf = zfile_fopen(fpath, _T("rb"));
1140 if (!zf) {
1141 console_out_f(_T("Couldn't open source file '%s'\n"), fpath);
1142 return false;
1143 }
1144 int length;
1145 uae_u8 *data2 = zfile_getdata(zf, 0, -1, &length);
1146 if (!data2) {
1147 zfile_fclose(zf);
1148 console_out_f(_T("Couldn't read source file '%s'\n"), fpath);
1149 return false;
1150 }
1151 uae_u8 *data = xcalloc(uae_u8, length + 1);
1152 memcpy(data, data2, length);
1153 xfree(data2);
1154 zfile_fclose(zf);
1155 cf->data = data;
1156 cf->length = length;
1157 cf->lines = 1;
1158 for (int i = 0; i < length; i++) {
1159 if (data[i] == 0) {
1160 data[i] = 32;
1161 }
1162 if (data[i] == 10) {
1163 data[i] = 0;
1164 cf->lines++;
1165 }
1166 }
1167 cf->lineptr = xcalloc(uae_u8*, 1 + cf->lines + 2);
1168 int linecnt = 1;
1169 int lasti = 0;
1170 for (int i = 0; i <= length; i++) {
1171 if (data[i] == 0) {
1172 uae_u8 *s = &data[lasti];
1173 lasti = i + 1;
1174 if (strlen((char*)s) >= MAX_SOURCELINELEN) {
1175 s[MAX_SOURCELINELEN] = 0;
1176 }
1177 cf->lineptr[linecnt++] = s;
1178 int len = uaestrlen((char*)s);
1179 if (len > 0 && s[len - 1] == 13)
1180 s[len - 1] = 0;
1181 }
1182 }
1183 return true;
1184}
1185
1186static struct debugcodefile *preallocatecodefile(const TCHAR *path, const TCHAR *name)
1187{

Callers 2

loadcodefileFunction · 0.85
debugmem_get_sourcelineFunction · 0.85

Calls 4

zfile_fopenFunction · 0.85
zfile_getdataFunction · 0.85
zfile_fcloseFunction · 0.85
console_out_fFunction · 0.50

Tested by

no test coverage detected