home *** CD-ROM | disk | FTP | other *** search
/ Sams Teach Yourself C in 21 Days (6th Edition) / STYC216E.ISO / mac / Examples / Day10 / memalloc.c < prev    next >
MacBinary  |  2002-06-08  |  1.5 KB  |  [TEXT/LMAN]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
66% dexvert Compact Compressed (Unix) (archive/compact) ext Supported
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, Sat Jun 8 20:20:38 2002, modified Sat Jun 8 20:20:38 2002, creator 'LMAN', type ASCII, 920 bytes "memalloc.c" , at 0x418 286 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[LMAN]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0a 6d 65 6d 61 6c 6c | 6f 63 2e 63 00 00 00 00 |..memall|oc.c....|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4c 4d 41 | 4e 00 00 ff ff ff ff 00 |.TEXTLMA|N.......|
|00000050| 00 00 00 00 00 03 98 00 | 00 01 1e b9 28 4f d6 b9 |........|....(O..|
|00000060| 28 4f d6 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |(O......|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 d7 ac 00 00 |........|........|
|00000080| 2f 2a 20 44 65 6d 6f 6e | 73 74 72 61 74 65 73 20 |/* Demon|strates |
|00000090| 74 68 65 20 75 73 65 20 | 6f 66 20 6d 61 6c 6c 6f |the use |of mallo|
|000000a0| 63 28 29 20 74 6f 20 61 | 6c 6c 6f 63 61 74 65 20 |c() to a|llocate |
|000000b0| 73 74 6f 72 61 67 65 20 | 2a 2f 0d 0a 2f 2a 20 73 |storage |*/../* s|
|000000c0| 70 61 63 65 20 66 6f 72 | 20 73 74 72 69 6e 67 20 |pace for| string |
|000000d0| 64 61 74 61 2e 20 2a 2f | 0d 0a 0d 0a 23 69 6e 63 |data. */|....#inc|
|000000e0| 6c 75 64 65 20 3c 73 74 | 64 69 6f 2e 68 3e 0d 0a |lude <st|dio.h>..|
|000000f0| 23 69 6e 63 6c 75 64 65 | 20 3c 73 74 64 6c 69 62 |#include| <stdlib|
|00000100| 2e 68 3e 0d 0a 0d 0a 63 | 68 61 72 20 63 6f 75 6e |.h>....c|har coun|
|00000110| 74 2c 20 2a 70 74 72 2c | 20 2a 70 3b 0d 0a 0d 0a |t, *ptr,| *p;....|
|00000120| 69 6e 74 20 6d 61 69 6e | 28 20 76 6f 69 64 20 29 |int main|( void )|
|00000130| 0d 0a 7b 0d 0a 20 20 20 | 2f 2a 20 41 6c 6c 6f 63 |..{.. |/* Alloc|
|00000140| 61 74 65 20 61 20 62 6c | 6f 63 6b 20 6f 66 20 33 |ate a bl|ock of 3|
|00000150| 35 20 62 79 74 65 73 2e | 20 54 65 73 74 20 66 6f |5 bytes.| Test fo|
|00000160| 72 20 73 75 63 63 65 73 | 73 2e 20 2a 2f 0d 0a 20 |r succes|s. */.. |
|00000170| 20 20 2f 2a 20 54 68 65 | 20 65 78 69 74 28 29 20 | /* The| exit() |
|00000180| 6c 69 62 72 61 72 79 20 | 66 75 6e 63 74 69 6f 6e |library |function|
|00000190| 20 74 65 72 6d 69 6e 61 | 74 65 73 20 74 68 65 20 | termina|tes the |
|000001a0| 70 72 6f 67 72 61 6d 2e | 20 2a 2f 0d 0a 0d 0a 20 |program.| */.... |
|000001b0| 20 20 70 74 72 20 3d 20 | 6d 61 6c 6c 6f 63 28 33 | ptr = |malloc(3|
|000001c0| 35 20 2a 20 73 69 7a 65 | 6f 66 28 63 68 61 72 29 |5 * size|of(char)|
|000001d0| 29 3b 0d 0a 0d 0a 20 20 | 20 69 66 20 28 70 74 72 |);.... | if (ptr|
|000001e0| 20 3d 3d 20 4e 55 4c 4c | 29 0d 0a 20 20 20 7b 0d | == NULL|).. {.|
|000001f0| 0a 20 20 20 20 20 20 20 | 70 75 74 73 28 22 4d 65 |. |puts("Me|
|00000200| 6d 6f 72 79 20 61 6c 6c | 6f 63 61 74 69 6f 6e 20 |mory all|ocation |
|00000210| 65 72 72 6f 72 2e 22 29 | 3b 0d 0a 20 20 20 20 20 |error.")|;.. |
|00000220| 20 20 72 65 74 75 72 6e | 20 31 3b 0d 0a 20 20 20 | return| 1;.. |
|00000230| 7d 0d 0a 0d 0a 20 20 20 | 2f 2a 20 46 69 6c 6c 20 |}.... |/* Fill |
|00000240| 74 68 65 20 73 74 72 69 | 6e 67 20 77 69 74 68 20 |the stri|ng with |
|00000250| 76 61 6c 75 65 73 20 36 | 35 20 74 68 72 6f 75 67 |values 6|5 throug|
|00000260| 68 20 39 30 2c 20 2a 2f | 0d 0a 20 20 20 2f 2a 20 |h 90, */|.. /* |
|00000270| 77 68 69 63 68 20 61 72 | 65 20 74 68 65 20 41 53 |which ar|e the AS|
|00000280| 43 49 49 20 63 6f 64 65 | 73 20 66 6f 72 20 41 2d |CII code|s for A-|
|00000290| 5a 2e 20 2a 2f 0d 0a 0d | 0a 20 20 20 2f 2a 20 70 |Z. */...|. /* p|
|000002a0| 20 69 73 20 61 20 70 6f | 69 6e 74 65 72 20 75 73 | is a po|inter us|
|000002b0| 65 64 20 74 6f 20 73 74 | 65 70 20 74 68 72 6f 75 |ed to st|ep throu|
|000002c0| 67 68 20 74 68 65 20 73 | 74 72 69 6e 67 2e 20 2a |gh the s|tring. *|
|000002d0| 2f 0d 0a 20 20 20 2f 2a | 20 59 6f 75 20 77 61 6e |/.. /*| You wan|
|000002e0| 74 20 70 74 72 20 74 6f | 20 72 65 6d 61 69 6e 20 |t ptr to| remain |
|000002f0| 70 6f 69 6e 74 65 64 20 | 61 74 20 74 68 65 20 73 |pointed |at the s|
|00000300| 74 61 72 74 20 2a 2f 0d | 0a 20 20 20 2f 2a 20 6f |tart */.|. /* o|
|00000310| 66 20 74 68 65 20 73 74 | 72 69 6e 67 2e 20 2a 2f |f the st|ring. */|
|00000320| 0d 0a 0d 0a 20 20 20 70 | 20 3d 20 70 74 72 3b 0d |.... p| = ptr;.|
|00000330| 0a 0d 0a 20 20 20 66 6f | 72 20 28 63 6f 75 6e 74 |... fo|r (count|
|00000340| 20 3d 20 36 35 3b 20 63 | 6f 75 6e 74 20 3c 20 39 | = 65; c|ount < 9|
|00000350| 31 20 3b 20 63 6f 75 6e | 74 2b 2b 29 0d 0a 20 20 |1 ; coun|t++).. |
|00000360| 20 20 20 20 20 2a 70 2b | 2b 20 3d 20 63 6f 75 6e | *p+|+ = coun|
|00000370| 74 3b 0d 0a 0d 0a 20 20 | 20 2f 2a 20 41 64 64 20 |t;.... | /* Add |
|00000380| 74 68 65 20 74 65 72 6d | 69 6e 61 74 69 6e 67 20 |the term|inating |
|00000390| 6e 75 6c 6c 20 63 68 61 | 72 61 63 74 65 72 2e 20 |null cha|racter. |
|000003a0| 2a 2f 0d 0a 0d 0a 20 20 | 20 2a 70 20 3d 20 27 5c |*/.... | *p = '\|
|000003b0| 30 27 3b 0d 0a 0d 0a 20 | 20 20 2f 2a 20 44 69 73 |0';.... | /* Dis|
|000003c0| 70 6c 61 79 20 74 68 65 | 20 73 74 72 69 6e 67 20 |play the| string |
|000003d0| 6f 6e 20 74 68 65 20 73 | 63 72 65 65 6e 2e 20 2a |on the s|creen. *|
|000003e0| 2f 0d 0a 0d 0a 20 20 20 | 70 75 74 73 28 70 74 72 |/.... |puts(ptr|
|000003f0| 29 3b 0d 0a 0d 0a 20 20 | 20 66 72 65 65 28 70 74 |);.... | free(pt|
|00000400| 72 29 3b 0d 0a 0d 0a 20 | 20 20 72 65 74 75 72 6e |r);.... | return|
|00000410| 20 30 3b 0d 0a 7d 0d 0a | 00 00 00 00 00 00 00 00 | 0;..}..|........|
|00000420| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000430| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000440| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000450| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000460| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000470| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000480| 00 00 01 00 00 00 01 00 | 00 00 00 00 00 00 00 1e |........|........|
|00000490| 54 68 69 73 20 72 65 73 | 6f 75 72 63 65 20 66 6f |This res|ource fo|
|000004a0| 72 6b 20 69 6e 74 65 6e | 74 69 6f 6e 61 6c 6c 79 |rk inten|tionally|
|000004b0| 20 6c 65 66 74 20 62 6c | 61 6e 6b 20 20 20 00 00 | left bl|ank ..|
|000004c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000004d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000004e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000004f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000500| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000510| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000520| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000530| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000540| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000550| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000560| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000570| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000580| 00 00 01 00 00 00 01 00 | 00 00 00 00 00 00 00 1e |........|........|
|00000590| 00 00 00 00 00 00 00 00 | 00 1c 00 1e ff ff 00 00 |........|........|
|000005a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000005b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000005c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000005d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000005e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000005f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+