Changeset 781 for soft/giet_vm
- Timestamp:
- Feb 7, 2016, 7:47:38 PM (9 years ago)
- Location:
- soft/giet_vm/giet_libs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_libs/malloc.c
r777 r781 412 412 } 413 413 414 // reset the alloc[index] entry 415 *pchar = 0; 416 414 417 // call the recursive function update_free_array() 415 418 update_free_array( &heap[x][y], base, size_index ); -
soft/giet_vm/giet_libs/malloc.h
r777 r781 12 12 // Free blocks organisation: 13 13 // - All free blocks have a size that is a power of 2, larger or equal 14 // to MIN_BLOCK_SIZE (typically 128bytes).14 // to MIN_BLOCK_SIZE (typically 64 bytes). 15 15 // - All free blocks are aligned. 16 16 // - They are pre-classed in NB_SIZES linked lists, where all blocks in a … … 47 47 // of the allocated block must be obtained from the base address of the block. 48 48 // - The number of entries in this array is equal to the max number 49 // of allocated block is : heap_size / 128.49 // of allocated block is : heap_size / MIN_BLOCK_SIZE. 50 50 // - For each allocated block, the value registered in the alloc[] array 51 51 // is log2( size_of_allocated_block ). -
soft/giet_vm/giet_libs/string.c
r777 r781 6 6 /////////////////////////////////////////////////////////////////////////////////// 7 7 8 /////////////////////////////////////////////////////////////////////////////////// 9 // char * strcpy (char * destination, const char * source) 10 /////////////////////////////////////////////////////////////////////////////////// 8 /////////////////////////////////////////////////////// 11 9 char * strcpy (char * destination, const char * source) 12 10 { 13 if (!destination || !source) { 14 return destination; 15 } 11 if (!destination || !source) return destination; 16 12 17 while (*source) { 18 *(destination++) = *(source++); 19 } 13 char* src = source; 14 char* dst = destination; 15 do 16 { 17 *dst = *src; 18 dst++; 19 src++; 20 } while (*src); 21 22 *dst = 0; 20 23 21 24 return destination; … … 23 26 24 27 25 /////////////////////////////////////////////////////////////////////////////////// 26 // char * strncpy (char * destination, const char * source, int maxlen) 27 /////////////////////////////////////////////////////////////////////////////////// 28 //////////////////////////////////////////////////// 28 29 char * strncpy(char * dest, const char * src, int n) 29 30 { 30 31 int i; 31 for (i = 0; i < n && src[i] != '\0'; i++) { 32 for (i = 0; i < n && src[i] != '\0'; i++) 33 { 32 34 dest[i] = src[i]; 33 35 } 34 for (; i < n ; i++) { 36 for (; i < n ; i++) 37 { 35 38 dest[i] = '\0'; 36 39 } 40 37 41 return dest; 38 42 } 39 43 40 44 41 /////////////////////////////////////////////////////////////////////////////////// 42 // int strcmp (const char * str1, const char * str2) 43 /////////////////////////////////////////////////////////////////////////////////// 45 ///////////////////////////////////////////////// 44 46 int strcmp (const char * str1, const char * str2) 45 47 { 46 if (!str1 || !str2) { 47 return -123456; // return a value out of the char's bounds 48 if (!str1 || !str2) 49 { 50 return -123456; // return a value out of the char's bounds 48 51 } 49 52 50 while (*str1 && *str1 == *str2) { 53 while (*str1 && *str1 == *str2) 54 { 51 55 str1++; 52 56 str2++; … … 56 60 } 57 61 58 /////////////////////////////////////////////////////////////////////////////////// 59 // int strlen ( const char * str ) 60 /////////////////////////////////////////////////////////////////////////////////// 62 ///////////////////////////// 61 63 int strlen (const char * str) 62 64 { 63 65 const char * s = str; 64 66 65 while (*s) { 67 while (*s) 68 { 66 69 s++; 67 70 } … … 70 73 71 74 72 /////////////////////////////////////////////////////////////////////////////////// 73 // char * strchr(const char * str) 74 /////////////////////////////////////////////////////////////////////////////////// 75 ////////////////////////////////////// 75 76 char * strchr(const char * str, int c) 76 77 { 77 78 const char * s = str; 78 79 const char ch = c; 79 while (*s != ch && *s != '\0') { 80 while (*s != ch && *s != '\0') 81 { 80 82 s++; 81 83 } -
soft/giet_vm/giet_libs/string.h
r777 r781 10 10 11 11 //////////////////////////////////////////////////////////////////////////////////////// 12 // This function copies the source string to the dest string. 12 // This function copies the source string to the dest string, including the NUL 13 // terminating character. 13 14 // It returns a pointer on the dest string. 14 15 //////////////////////////////////////////////////////////////////////////////////////// … … 23 24 24 25 //////////////////////////////////////////////////////////////////////////////////////// 25 //The strcmp() function compares the two strings s1 and s2. It returns an integer less than, equal to, or greater than zero if s1 is found, respectively, to be less than, to match, or be greater than s2. 26 // The strcmp() function compares the two strings s1 and s2. It returns an integer 27 // less than, equal to, or greater than zero if s1 is found, respectively, to be smaller 28 // to match, or be greater than s2. 26 29 //////////////////////////////////////////////////////////////////////////////////////// 27 30 int strcmp(const char * str1, const char * str2);
Note: See TracChangeset
for help on using the changeset viewer.