[Horus] Malloc check added

This commit is contained in:
Bertrand Songis
2017-01-22 21:32:19 +01:00
parent 05129b6785
commit fb6c9cde6b
2 changed files with 53 additions and 30 deletions
+24 -24
View File
@@ -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);
}
}