Browse Source

Comment bugged _priv->fp malloc and fix malloc of easycsv *csv in easycsv_init

redesign
Pradana AUMARS 11 months ago
parent
commit
a8480a2fcf
  1. 8
      src/easycsv.c

8
src/easycsv.c

@ -201,7 +201,7 @@ easycsv_init_errormsg(const char *fp,
csv->start = clock();
#endif
easycsv *csv = malloc(sizeof(csv));
easycsv *csv = malloc(sizeof(easycsv));
csv->mode = mode;
csv->_priv = _easycsv_priv_init(fp, mode, error);
@ -728,9 +728,9 @@ _easycsv_priv_init(const char *fp,
size_t stfp = strlen(fp);
/* Allocate memory for char* */
_priv->fp = malloc(stfp + 1); // + 1 for null
// priv->fp = malloc(stfp + 1); // + 1 for null
strncpy(_priv->fp, fp, stfp);
// strncpy(_priv->fp, fp, stfp);
/* Calculate rows and cols if file exists */
if (access(_priv->fp, F_OK) == 0) {
@ -901,7 +901,7 @@ _easycsv_columns(_easycsv *_priv,
3. if >1 column, n commas = n+1 columns
*/
unsigned int col = 1;
int col = 1;
char c;
while ((c = fgetc(_priv->file)) != '\n') {

Loading…
Cancel
Save