00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00048 #include "splt.h"
00049
00050 void splt_se_set_sync_errors_default_values(splt_state *state)
00051 {
00052 splt_syncerrors *serrors = state->serrors;
00053
00054 state->syncerrors = 0;
00055 serrors->serrors_points = NULL;
00056 serrors->serrors_points_num = 0;
00057 }
00058
00059 int splt_se_serrors_append_point(splt_state *state, off_t point)
00060 {
00061 int error = SPLT_OK;
00062
00063 splt_syncerrors *serrors = state->serrors;
00064
00065 int serrors_num = serrors->serrors_points_num;
00066
00067 serrors->serrors_points_num++;
00068
00069 if (point >= 0)
00070 {
00071 if (serrors->serrors_points == NULL)
00072 {
00073 if((serrors->serrors_points =
00074 malloc(sizeof(off_t) * (serrors_num + 1))) == NULL)
00075 {
00076 error = SPLT_ERROR_CANNOT_ALLOCATE_MEMORY;
00077 }
00078 else
00079 {
00080 serrors->serrors_points[0] = 0;
00081 }
00082 }
00083 else
00084 {
00085 if((serrors->serrors_points = realloc(serrors->serrors_points,
00086 sizeof(off_t) * (serrors_num + 1))) == NULL)
00087 {
00088 error = SPLT_ERROR_CANNOT_ALLOCATE_MEMORY;
00089 }
00090 }
00091
00092 if (error == SPLT_OK)
00093 {
00094 serrors->serrors_points[serrors_num] = point;
00095
00096 if (point == -1)
00097 {
00098 error = SPLT_ERR_SYNC;
00099 }
00100 }
00101 }
00102 else
00103 {
00104 splt_e_error(SPLT_IERROR_INT, __func__, point, NULL);
00105 }
00106
00107 return error;
00108 }
00109
00110 void splt_se_serrors_free(splt_state *state)
00111 {
00112 splt_syncerrors *serrors = state->serrors;
00113
00114 if (!serrors)
00115 {
00116 return;
00117 }
00118
00119 if (serrors->serrors_points)
00120 {
00121 free(serrors->serrors_points);
00122 serrors->serrors_points = NULL;
00123 serrors->serrors_points_num = 0;
00124 }
00125 }
00126