Intermec 5055 Reference Guide
im_fmalloc
5-18
im_fmalloc
Purpose:
This function allocates a memory block larger than 64K.
Syntax:
#include "im5055.h"
void far *im_fmalloc
(IM_ULONG
void far *im_fmalloc
(IM_ULONG
lsize
)
IN Parameters:
lsize Size of memory in bytes to allocate.
OUT Parameters:
None.
Return Value:
This function returns one of these values:
Far void pointer Allocation was successful. The pointer indicates the allocated space.
NULL Not enough available free memory to allocate.
Notes:
The system uses 16 bytes of overhead. If you want to allocate the largest free memory
block available, specify lsize as 16 bytes less than the available memory block size.
block available, specify lsize as 16 bytes less than the available memory block size.
Example
/* Example of doing a set/get relay digital I/O */
#include <string.h>
#include "im5055.h"
#include <conio.h>
#include <stdlib.h>
void main (void)
{
IM_ULONG lsize;
IM_ULONG ltotal;
char *pz1;
char c;
/* Inquire about system memory */
im_free_mem(&lsize, <otal);
printf("Largest size: %ld\nTotalsize:%ld\n", lsize, ltotal);
/* Allocate the largest block, it must be 16 bytes less than block size */
pz1 = im_fmalloc(lsize – 16L);
if (pz1 == NULL)
{
im_cputs("Fails to allocate memory\n", IM_NORMAL);
}
else
{
free(pz1);
}
c = getch();
#include <string.h>
#include "im5055.h"
#include <conio.h>
#include <stdlib.h>
void main (void)
{
IM_ULONG lsize;
IM_ULONG ltotal;
char *pz1;
char c;
/* Inquire about system memory */
im_free_mem(&lsize, <otal);
printf("Largest size: %ld\nTotalsize:%ld\n", lsize, ltotal);
/* Allocate the largest block, it must be 16 bytes less than block size */
pz1 = im_fmalloc(lsize – 16L);
if (pz1 == NULL)
{
im_cputs("Fails to allocate memory\n", IM_NORMAL);
}
else
{
free(pz1);
}
c = getch();