Changeset 44e8541 in mainline
- Timestamp:
- 2023-10-27T17:38:32Z (13 months ago)
- Branches:
- master, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fdfb24e
- Parents:
- b169619
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-10-27 15:17:18)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-10-27 17:38:32)
- Files:
-
- 1 deleted
- 8 edited
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
common/include/stdlib.h
rb169619 r44e8541 41 41 #include <_bits/decls.h> 42 42 #include <bsearch.h> 43 #include <malloc.h>44 43 #include <qsort.h> 45 44 … … 109 108 extern lldiv_t lldiv(long long, long long); 110 109 110 extern void *malloc(size_t size) 111 __attribute__((malloc)); 112 extern void *calloc(size_t nmemb, size_t size) 113 __attribute__((malloc)); 114 extern void *realloc(void *addr, size_t size) 115 __attribute__((warn_unused_result)); 116 extern void free(void *addr); 117 118 #ifdef _HELENOS_SOURCE 119 __HELENOS_DECLS_BEGIN; 120 121 extern void *memalign(size_t align, size_t size) 122 __attribute__((malloc)); 123 124 __HELENOS_DECLS_END; 125 #endif 126 111 127 __C_DECLS_END; 112 128 -
common/stdc/calloc.c
rb169619 r44e8541 1 1 /* 2 * Copyright (c) 2006 Ondrej Palkovsky 2 * Copyright (c) 2009 Martin Decky 3 * Copyright (c) 2009 Petr Tuma 3 4 * All rights reserved. 4 5 * … … 27 28 */ 28 29 29 /** @addtogroup kernel_generic_mm 30 * @{ 30 #include <stdlib.h> 31 32 #include <mem.h> 33 34 /** Allocate memory by number of elements 35 * 36 * @param nmemb Number of members to allocate. 37 * @param size Size of one member in bytes. 38 * 39 * @return Allocated memory or NULL. 40 * 31 41 */ 32 /** @file 33 */ 42 void *calloc(const size_t nmemb, const size_t size) 43 { 44 // Check for overflow 45 if (SIZE_MAX / size < nmemb) 46 return NULL; 34 47 35 #ifndef KERN_STDLIB_H_ 36 #define KERN_STDLIB_H_ 48 void *block = malloc(nmemb * size); 49 if (block == NULL) 50 return NULL; 37 51 38 #include <stddef.h> 39 40 extern void *malloc(size_t) 41 __attribute__((malloc)); 42 extern void *realloc(void *, size_t) 43 __attribute__((warn_unused_result)); 44 extern void free(void *); 45 46 #endif 47 48 /** @} 49 */ 52 memset(block, 0, nmemb * size); 53 return block; 54 } -
uspace/app/tester/mm/common.c
rb169619 r44e8541 35 35 #include <stdlib.h> 36 36 #include <errno.h> 37 #include <malloc.h> 37 38 #include "../tester.h" 38 39 #include "common.h" -
uspace/lib/c/generic/malloc.c
rb169619 r44e8541 34 34 */ 35 35 36 #include < malloc.h>36 #include <stdlib.h> 37 37 #include <stdalign.h> 38 38 #include <stdbool.h> … … 47 47 #include <stdlib.h> 48 48 #include <adt/gcdlcm.h> 49 #include <malloc.h> 49 50 50 51 #include "private/malloc.h" … … 773 774 } 774 775 775 /** Allocate memory by number of elements776 *777 * @param nmemb Number of members to allocate.778 * @param size Size of one member in bytes.779 *780 * @return Allocated memory or NULL.781 *782 */783 void *calloc(const size_t nmemb, const size_t size)784 {785 // FIXME: Check for overflow786 787 void *block = malloc(nmemb * size);788 if (block == NULL)789 return NULL;790 791 memset(block, 0, nmemb * size);792 return block;793 }794 795 776 /** Allocate memory 796 777 * -
uspace/lib/c/include/malloc.h
rb169619 r44e8541 39 39 #include <_bits/decls.h> 40 40 41 __C_DECLS_BEGIN;42 43 extern void *malloc(size_t size)44 __attribute__((malloc));45 extern void *calloc(size_t nmemb, size_t size)46 __attribute__((malloc));47 extern void *realloc(void *addr, size_t size)48 __attribute__((warn_unused_result));49 extern void free(void *addr);50 51 __C_DECLS_END;52 53 41 #ifdef _HELENOS_SOURCE 54 42 __HELENOS_DECLS_BEGIN; 55 43 56 extern void *memalign(size_t align, size_t size)57 __attribute__((malloc));58 44 extern void *heap_check(void); 59 45 -
uspace/lib/c/meson.build
rb169619 r44e8541 62 62 src += files( 63 63 'common/stdc/mem.c', 64 'common/stdc/bsearch.c', 65 'common/stdc/qsort.c', 66 'common/stdc/calloc.c', 67 64 68 'generic/libc.c', 65 69 'generic/as.c', … … 160 164 'generic/stats.c', 161 165 'generic/assert.c', 162 'generic/bsearch.c',163 'generic/qsort.c',164 166 'generic/ubsan.c', 165 167 'generic/uuid.c', -
uspace/lib/posix/include/posix/stdlib.h
rb169619 r44e8541 37 37 #define POSIX_STDLIB_H_ 38 38 39 #include < libc/stdlib.h>39 #include <common/stdlib.h> 40 40 #include <sys/types.h> 41 41 -
uspace/lib/posix/src/stdio.c
rb169619 r44e8541 55 55 #include <io/printf_core.h> 56 56 #include <str.h> 57 #include < malloc.h>57 #include <stdlib.h> 58 58 #include <adt/list.h> 59 59 -
uspace/lib/posix/src/time.c
rb169619 r44e8541 47 47 48 48 #include <fibril.h> 49 #include < malloc.h>49 #include <stdlib.h> 50 50 #include <task.h> 51 51 #include <stddef.h> -
uspace/lib/posix/src/unistd.c
rb169619 r44e8541 50 50 #include <task.h> 51 51 #include <stats.h> 52 #include < malloc.h>52 #include <stdlib.h> 53 53 #include <vfs/vfs.h> 54 54
Note:
See TracChangeset
for help on using the changeset viewer.