imapext-2007
diff src/osdep/amiga/fs_ami.c @ 0:ada5e610ab86
imap-2007e
author | yuuji@gentei.org |
---|---|
date | Mon, 14 Sep 2009 15:17:45 +0900 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/osdep/amiga/fs_ami.c Mon Sep 14 15:17:45 2009 +0900 1.3 @@ -0,0 +1,71 @@ 1.4 +/* ======================================================================== 1.5 + * Copyright 1988-2006 University of Washington 1.6 + * 1.7 + * Licensed under the Apache License, Version 2.0 (the "License"); 1.8 + * you may not use this file except in compliance with the License. 1.9 + * You may obtain a copy of the License at 1.10 + * 1.11 + * http://www.apache.org/licenses/LICENSE-2.0 1.12 + * 1.13 + * 1.14 + * ======================================================================== 1.15 + */ 1.16 + 1.17 +/* 1.18 + * Program: Free storage management routines 1.19 + * 1.20 + * Author: Mark Crispin 1.21 + * Networks and Distributed Computing 1.22 + * Computing & Communications 1.23 + * University of Washington 1.24 + * Administration Building, AG-44 1.25 + * Seattle, WA 98195 1.26 + * Internet: MRC@CAC.Washington.EDU 1.27 + * 1.28 + * Date: 1 August 1988 1.29 + * Last Edited: 30 August 2006 1.30 + */ 1.31 + 1.32 +/* Get a block of free storage 1.33 + * Accepts: size of desired block 1.34 + * Returns: free storage block 1.35 + */ 1.36 + 1.37 +void *fs_get (size_t size) 1.38 +{ 1.39 + blocknotify_t bn = (blocknotify_t) mail_parameters (NIL,GET_BLOCKNOTIFY,NIL); 1.40 + void *data = (*bn) (BLOCK_SENSITIVE,NIL); 1.41 + void *block = malloc (size ? size : (size_t) 1); 1.42 + if (!block) fatal ("Out of memory"); 1.43 + (*bn) (BLOCK_NONSENSITIVE,data); 1.44 + return (block); 1.45 +} 1.46 + 1.47 + 1.48 +/* Resize a block of free storage 1.49 + * Accepts: ** pointer to current block 1.50 + * new size 1.51 + */ 1.52 + 1.53 +void fs_resize (void **block,size_t size) 1.54 +{ 1.55 + blocknotify_t bn = (blocknotify_t) mail_parameters (NIL,GET_BLOCKNOTIFY,NIL); 1.56 + void *data = (*bn) (BLOCK_SENSITIVE,NIL); 1.57 + if (!(*block = realloc (*block,size ? size : (size_t) 1))) 1.58 + fatal ("Can't resize memory"); 1.59 + (*bn) (BLOCK_NONSENSITIVE,data); 1.60 +} 1.61 + 1.62 + 1.63 +/* Return a block of free storage 1.64 + * Accepts: ** pointer to free storage block 1.65 + */ 1.66 + 1.67 +void fs_give (void **block) 1.68 +{ 1.69 + blocknotify_t bn = (blocknotify_t) mail_parameters (NIL,GET_BLOCKNOTIFY,NIL); 1.70 + void *data = (*bn) (BLOCK_SENSITIVE,NIL); 1.71 + free (*block); 1.72 + *block = NIL; 1.73 + (*bn) (BLOCK_NONSENSITIVE,data); 1.74 +}