File: util.c

package info (click to toggle)
hivelytracker 0+git20180223-3
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 3,092 kB
  • sloc: ansic: 19,601; objc: 434; cpp: 175; makefile: 88
file content (41 lines) | stat: -rwxr-xr-x 973 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>

#include <system_includes.h>

#ifndef __SDL_WRAPPER__
/*
** A small routine to open a library and get its default
** interface, and report errors if anything fails.
*/
BOOL getLibIFace( struct Library **libbase, TEXT *libname, uint32 version, void *ifaceptr )
{
  struct Interface **ifptr = (struct Interface **)ifaceptr;

  *libbase = IExec->OpenLibrary( libname, version );
  if( *libbase == NULL )
  {
    printf( "Unable to open '%s' version %ld\n", libname, version );
    return FALSE;
  }

  *ifptr = IExec->GetInterface( *libbase, "main", 1, NULL );
  if( *ifptr == NULL )
  {
    printf( "Unable to get the main interface for '%s'\n", libname );
    return FALSE;
  }

  return TRUE;
}
#endif

struct Node *allocnode(int32 size)
{
#ifndef __SDL_WRAPPER__
  return IExec->AllocSysObjectTags(ASOT_NODE, ASONODE_Size, size, TAG_DONE);
#else
  struct Node *ptr = malloc(size);
  if (ptr) memset(ptr, 0, sizeof(struct Node));
  return ptr;
#endif
}