mirror of
https://github.com/mpv-player/mpv
synced 2024-12-21 22:30:22 +00:00
Portability fix with realloc
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@5803 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
74ce925bb3
commit
e87d472777
@ -264,7 +264,12 @@ asx_get_element(ASX_Parser_t* parser,char** _buffer,
|
||||
if( i < parser->ret_stack_size)
|
||||
memmove(parser->ret_stack,parser->ret_stack+i, (parser->ret_stack_size - i)*sizeof(ASX_LineSave_t));
|
||||
parser->ret_stack_size -= i;
|
||||
parser->ret_stack = (ASX_LineSave_t*)realloc(parser->ret_stack,parser->ret_stack_size*sizeof(ASX_LineSave_t));
|
||||
if(parser->ret_stack_size > 0)
|
||||
parser->ret_stack = (ASX_LineSave_t*)realloc(parser->ret_stack,parser->ret_stack_size*sizeof(ASX_LineSave_t));
|
||||
else {
|
||||
free(parser->ret_stack);
|
||||
parser->ret_stack = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -605,7 +605,12 @@ play_tree_iter_up_step(play_tree_iter_t* iter, int d,int with_nodes) {
|
||||
|
||||
iter->stack_size--;
|
||||
iter->loop = iter->status_stack[iter->stack_size];
|
||||
iter->status_stack = (int*)realloc(iter->status_stack,iter->stack_size*sizeof(int));
|
||||
if(iter->stack_size > 0)
|
||||
iter->status_stack = (int*)realloc(iter->status_stack,iter->stack_size*sizeof(int));
|
||||
else {
|
||||
free(iter->status_stack);
|
||||
iter->status_stack = NULL;
|
||||
}
|
||||
if(iter->stack_size > 0 && iter->status_stack == NULL) {
|
||||
mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Can't allocate %d bytes of memory\n",iter->stack_size*sizeof(char*));
|
||||
return PLAY_TREE_ITER_ERROR;
|
||||
|
@ -49,7 +49,7 @@ play_tree_parser_get_line(play_tree_parser_t* p) {
|
||||
p->iter = p->buffer;
|
||||
}
|
||||
|
||||
if(p->stream->eof && p->buffer_end == 0)
|
||||
if(p->stream->eof && (p->buffer_end == 0 || p->iter[0] == '\0'))
|
||||
return NULL;
|
||||
|
||||
while(1) {
|
||||
@ -83,12 +83,14 @@ play_tree_parser_get_line(play_tree_parser_t* p) {
|
||||
}
|
||||
|
||||
line_end = ((*(end-1)) == '\r') ? end-1 : end;
|
||||
p->line = (char*)realloc(p->line,line_end - p->iter+1);
|
||||
if(!p->line)
|
||||
if(line_end - p->iter >= 0)
|
||||
p->line = (char*)realloc(p->line,line_end - p->iter+1);
|
||||
else
|
||||
return NULL;
|
||||
strncpy(p->line,p->iter,line_end - p->iter);
|
||||
if(line_end - p->iter > 0)
|
||||
strncpy(p->line,p->iter,line_end - p->iter);
|
||||
p->line[line_end - p->iter] = '\0';
|
||||
if(end != '\0')
|
||||
if(end[0] != '\0')
|
||||
end++;
|
||||
|
||||
if(!p->keep) {
|
||||
|
Loading…
Reference in New Issue
Block a user