| OLD | NEW |
| 1 /* libFLAC - Free Lossless Audio Codec library | 1 /* libFLAC - Free Lossless Audio Codec library |
| 2 * Copyright (C) 2001-2009 Josh Coalson | 2 * Copyright (C) 2001-2009 Josh Coalson |
| 3 * Copyright (C) 2011-2014 Xiph.Org Foundation | 3 * Copyright (C) 2011-2014 Xiph.Org Foundation |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * - Redistributions of source code must retain the above copyright | 9 * - Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #ifdef HAVE_CONFIG_H | 33 #ifdef HAVE_CONFIG_H |
| 34 # include <config.h> | 34 # include <config.h> |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 #ifdef HAVE_STDINT_H | 37 #ifdef HAVE_STDINT_H |
| 38 #include <stdint.h> | 38 #include <stdint.h> |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 #include "private/memory.h" | 41 #include "private/memory.h" |
| 42 #include "FLAC/assert.h" | 42 #include "FLAC/assert.h" |
| 43 #include "share/compat.h" |
| 43 #include "share/alloc.h" | 44 #include "share/alloc.h" |
| 44 | 45 |
| 45 void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address) | 46 void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address) |
| 46 { | 47 { |
| 47 void *x; | 48 void *x; |
| 48 | 49 |
| 49 FLAC__ASSERT(0 != aligned_address); | 50 FLAC__ASSERT(0 != aligned_address); |
| 50 | 51 |
| 51 #ifdef FLAC__ALIGN_MALLOC_DATA | 52 #ifdef FLAC__ALIGN_MALLOC_DATA |
| 52 /* align on 32-byte (256-bit) boundary */ | 53 /* align on 32-byte (256-bit) boundary */ |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 #endif | 210 #endif |
| 210 | 211 |
| 211 void *safe_malloc_mul_2op_p(size_t size1, size_t size2) | 212 void *safe_malloc_mul_2op_p(size_t size1, size_t size2) |
| 212 { | 213 { |
| 213 if(!size1 || !size2) | 214 if(!size1 || !size2) |
| 214 return malloc(1); /* malloc(0) is undefined; FLAC src convention
is to always allocate */ | 215 return malloc(1); /* malloc(0) is undefined; FLAC src convention
is to always allocate */ |
| 215 if(size1 > SIZE_MAX / size2) | 216 if(size1 > SIZE_MAX / size2) |
| 216 return 0; | 217 return 0; |
| 217 return malloc(size1*size2); | 218 return malloc(size1*size2); |
| 218 } | 219 } |
| OLD | NEW |