[Horus] Malloc check added
This commit is contained in:
+24
-24
@@ -1,23 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file syscalls.c
|
||||
*
|
||||
@@ -54,17 +54,17 @@ extern void _exit( int status ) ;
|
||||
extern void _kill( int pid, int sig ) ;
|
||||
extern int _getpid ( void ) ;
|
||||
|
||||
unsigned char *heap = (unsigned char *)&_end;
|
||||
unsigned char * heap = (unsigned char *)&_end;
|
||||
extern caddr_t _sbrk(int nbytes)
|
||||
{
|
||||
if (heap + nbytes < (unsigned char *)&_heap_end) {
|
||||
unsigned char *prev_heap = heap;
|
||||
unsigned char * prev_heap = heap;
|
||||
heap += nbytes;
|
||||
return (caddr_t) prev_heap;
|
||||
return (caddr_t)prev_heap;
|
||||
}
|
||||
else {
|
||||
errno = ENOMEM;
|
||||
return ((void*)-1);
|
||||
return ((void *)-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user