I have the following code designed to convert an NSMutableString to an NSData:
-(NSData *)desSerializarFirma:(NSMutableString *)firma{ NSArray *arregloBits = [firma componentsSeparatedByString:@","]; unsigned c = arregloBits.count; uint8_t *bytes = malloc(sizeof(*bytes) * c); unsigned i; for (i = 0; i < c; i ++) { NSString *str = [arregloBits objectAtIndex:i]; int byte = [str intValue]; bytes[i] = (uint8_t)byte; } return [NSData dataWithBytes:bytes length:c]; }
when I parse this with xcode, it says
memory is never released; potential leak of memory pointed to by 'bytes'
this statement points to the last line of my code:
return [NSData dataWithBytes:bytes length:c];
if I free the object by doing "free (bytes)" then I get my function useless ... any help I would appreciate
source share