Addressed an 'unallocated memory' warning generated by clang.

This commit is contained in:
Ward Fisher 2015-02-23 13:38:18 -07:00
parent cc260fc9aa
commit a8494773f8

View File

@ -115,7 +115,7 @@ new_NC_attr(
free(name);
if(strp == NULL)
return NULL;
attrp = new_x_NC_attr(strp, type, nelems);
if(attrp == NULL)
{
@ -134,7 +134,10 @@ dup_NC_attr(const NC_attr *rattrp)
rattrp->type, rattrp->nelems);
if(attrp == NULL)
return NULL;
(void) memcpy(attrp->xvalue, rattrp->xvalue, rattrp->xsz);
if(attrp->xvalue == NULL)
attrp->xvalue = (void*)malloc(sizeof(void*)*rattrp->xsz);
(void) memcpy(attrp->xvalue, rattrp->xvalue, rattrp->xsz);
return attrp;
}
@ -176,7 +179,7 @@ void
free_NC_attrarrayV(NC_attrarray *ncap)
{
assert(ncap != NULL);
if(ncap->nalloc == 0)
return;
@ -265,7 +268,7 @@ incr_NC_attrarray(NC_attrarray *ncap, NC_attr *newelemp)
(ncap->nalloc + NC_ARRAY_GROWBY) * sizeof(NC_attr *));
if(vp == NULL)
return NC_ENOMEM;
ncap->value = vp;
ncap->nalloc += NC_ARRAY_GROWBY;
}
@ -362,7 +365,7 @@ NC_findattr(const NC_attrarray *ncap, const char *uname)
/*
* Look up by ncid, varid and name, return NULL if not found
*/
static int
static int
NC_lookupattr(int ncid,
int varid,
const char *name, /* attribute name */
@ -424,7 +427,7 @@ NC3_inq_attname(int ncid, int varid, int attnum, char *name)
}
int
int
NC3_inq_attid(int ncid, int varid, const char *name, int *attnump)
{
int status;
@ -441,7 +444,7 @@ NC3_inq_attid(int ncid, int varid, const char *name, int *attnump)
ncap = NC_attrarray0(ncp, varid);
if(ncap == NULL)
return NC_ENOTVAR;
attrpp = NC_findattr(ncap, name);
if(attrpp == NULL)
@ -577,7 +580,7 @@ NC3_del_att(int ncid, int varid, const char *uname)
char *name = (char *)utf8proc_NFC((const unsigned char *)uname);
if(name == NULL)
return NC_ENOMEM;
/* sortof inline NC_findattr() */
slen = strlen(name);
@ -1399,10 +1402,10 @@ NC3_put_att(
if(!NC_indef(ncp)) {
const size_t xsz = ncx_len_NC_attrV(type, nelems);
attrp = *attrpp; /* convenience */
if(xsz > attrp->xsz) return NC_ENOTINDEFINE;
/* else, we can reuse existing without redef */
attrp->xsz = xsz;
attrp->type = type;
attrp->nelems = nelems;
@ -1411,7 +1414,7 @@ NC3_put_att(
void *xp = attrp->xvalue;
status = dispatchput(&xp, nelems, (const void*)value, type, memtype);
}
set_NC_hdirty(ncp);
if(NC_doHsync(ncp)) {
@ -1512,4 +1515,3 @@ NC3_get_att(
status = NC_EBADTYPE;
return status;
}