1865 int *panFieldOffsetNew;
1866 int *panFieldSizeNew;
1867 int *panFieldDecimalsNew;
1868 char *pachFieldTypeNew;
1873 if (psDBF->nFields == 0)
1880 panFieldOffsetNew = (
int *)
malloc(
sizeof(
int) * psDBF->nFields);
1881 panFieldSizeNew = (
int *)
malloc(
sizeof(
int) * psDBF->nFields);
1882 panFieldDecimalsNew = (
int *)
malloc(
sizeof(
int) * psDBF->nFields);
1883 pachFieldTypeNew = (
char *)
malloc(
sizeof(
char) * psDBF->nFields);
1884 pszHeaderNew = (
char *)
malloc(
sizeof(
char) * 32 * psDBF->nFields);
1887 for (i = 0; i < psDBF->nFields; i++)
1889 panFieldSizeNew[i] = psDBF->panFieldSize[panMap[i]];
1890 panFieldDecimalsNew[i] = psDBF->panFieldDecimals[panMap[i]];
1891 pachFieldTypeNew[i] = psDBF->pachFieldType[panMap[i]];
1892 memcpy(pszHeaderNew + i * 32, psDBF->pszHeader + panMap[i] * 32, 32);
1894 panFieldOffsetNew[0] = 1;
1895 for (i = 1; i < psDBF->nFields; i++)
1897 panFieldOffsetNew[i] = panFieldOffsetNew[i - 1] + panFieldSizeNew[i - 1];
1900 free(psDBF->pszHeader);
1901 psDBF->pszHeader = pszHeaderNew;
1904 if (!(psDBF->bNoHeader && psDBF->nRecords == 0))
1907 psDBF->bNoHeader =
TRUE;
1911 pszRecord = (
char *)
malloc(
sizeof(
char) * psDBF->nRecordLength);
1912 pszRecordNew = (
char *)
malloc(
sizeof(
char) * psDBF->nRecordLength);
1915 for (iRecord = 0; iRecord < psDBF->nRecords; iRecord++)
1917 nRecordOffset = psDBF->nRecordLength * (
SAOffset)iRecord + psDBF->nHeaderLength;
1920 psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0);
1921 psDBF->sHooks.FRead(pszRecord, psDBF->nRecordLength, 1, psDBF->fp);
1923 pszRecordNew[0] = pszRecord[0];
1925 for (i = 0; i < psDBF->nFields; i++)
1927 memcpy(pszRecordNew + panFieldOffsetNew[i],
1928 pszRecord + psDBF->panFieldOffset[panMap[i]],
1929 psDBF->panFieldSize[panMap[i]]);
1933 psDBF->sHooks.FSeek(psDBF->fp, nRecordOffset, 0);
1934 psDBF->sHooks.FWrite(pszRecordNew, psDBF->nRecordLength, 1, psDBF->fp);
1942 free(psDBF->panFieldOffset);
1943 free(psDBF->panFieldSize);
1944 free(psDBF->panFieldDecimals);
1945 free(psDBF->pachFieldType);
1947 psDBF->panFieldOffset = panFieldOffsetNew;
1948 psDBF->panFieldSize = panFieldSizeNew;
1949 psDBF->panFieldDecimals = panFieldDecimalsNew;
1950 psDBF->pachFieldType = pachFieldTypeNew;
1952 psDBF->nCurrentRecord = -1;
1953 psDBF->bCurrentRecordModified =
FALSE;
static int DBFFlushRecord(DBFHandle psDBF)
void SHPAPI_CALL DBFUpdateHeader(DBFHandle psDBF)